Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1003 lines
30 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: cnvcrypt.h
  7. //
  8. // Contents: Temporary Hack for converting the (SDR) version of
  9. // CryptoAPI 2.0
  10. //----------------------------------------------------------------------------
  11. #ifndef __CNVCRYPT_H__
  12. #define __CNVCRYPT_H__
  13. #if(_WIN32_WINNT >= 0x0400)
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // In general all digest, Digest, DIGEST changed to: hash, Hash, HASH.
  18. // A Hack to get the old error codes to work
  19. #define CRMSG_E_GENERAL CRYPT_E_MSG_ERROR
  20. #define CERT_BAD_PARAMETER E_INVALIDARG
  21. #define CERT_BAD_LENGTH CRYPT_E_BAD_LEN
  22. #define CERT_BAD_ENCODE CRYPT_E_BAD_ENCODE
  23. #define CERT_OUT_OF_MEMORY E_OUTOFMEMORY
  24. #define CERT_MUST_COPY_ENCODED E_INVALIDARG
  25. #define CERT_OSS_ERROR CRYPT_E_OSS_ERROR
  26. #define CERT_STORE_BAD_PARAMETER E_INVALIDARG
  27. #define CERT_STORE_BAD_LEN CRYPT_E_BAD_LEN
  28. #define CERT_STORE_BAD_FLAGS E_INVALIDARG
  29. #define CERT_STORE_BAD_FILE CRYPT_E_FILE_ERROR
  30. #define CERT_STORE_NO_SUCH_PROPERTY CRYPT_E_NOT_FOUND
  31. #define CERT_STORE_ALREADY_IN_STORE CRYPT_E_EXISTS
  32. #define CERT_STORE_NOT_IMPLEMENTED E_NOTIMPL
  33. #define CERT_STORE_NOT_FOUND CRYPT_E_NOT_FOUND
  34. #define CERT_STORE_NO_CRYPT_PROV CRYPT_E_NO_PROVIDER
  35. #define CERT_STORE_SELF_SIGNED CRYPT_E_SELF_SIGNED
  36. #define CERT_STORE_DELETED_PREV CRYPT_E_DELETED_PREV
  37. #define CERT_HELPER_NO_MATCH CRYPT_E_NO_MATCH
  38. #define SCA_BAD_LEN_PARAMETER CRYPT_E_BAD_LEN
  39. #define SCA_BAD_PARAMETER E_INVALIDARG
  40. #define SCA_UNEXPECTED_MSG_TYPE CRYPT_E_UNEXPECTED_MSG_TYPE
  41. #define SCA_NO_CERT_KEY_PROV CRYPT_E_NO_KEY_PROPERTY
  42. #define SCA_NO_XCHG_CERT CRYPT_E_NO_DECRYPT_CERT
  43. #define SCA_BAD_MSG CRYPT_E_BAD_MSG
  44. // A Hack to get the old APIs to work
  45. #define CertStoreOpen CertOpenStore
  46. // Added dwFlags parameter to CertCloseStore
  47. #define CertStoreClose CertCloseStore
  48. #define CertStoreClean CertCleanStore
  49. #define CertStoreSave CertSaveStore
  50. #define CertStoreDuplicate CertDuplicateStore
  51. #define CertStoreAddCert CertAddEncodedCertificateToStore
  52. #define CertStoreAddCertContext CertAddCertificateContextToStore
  53. #define CertStoreAddCrl CertAddEncodedCRLToStore
  54. #define CertStoreAddCrlContext CertAddCRLContextToStore
  55. #define CertStoreDeleteCert CertDeleteCertificateFromStore
  56. #define CertStoreDeleteCrl CertDeleteCRLFromStore
  57. #define CertStoreEnumCert CertEnumCertificatesInStore
  58. #define CertStoreFindCert CertFindCertificateInStore
  59. #define CertStoreGetSubjectCert CertGetSubjectCertificateFromStore
  60. #define CertStoreGetCrl CertGetCRLFromStore
  61. #define CertStoreGetIssuerCert CertGetIssuerCertificateFromStore
  62. #define CertStoreCreateCert CertCreateCertificateContext
  63. #define CertStoreDuplicateCert CertDuplicateCertificateContext
  64. #define CertStoreSetCertProperty CertSetCertificateContextProperty
  65. #define CertStoreGetCertProperty CertGetCertificateContextProperty
  66. #define CertStoreFreeCert CertFreeCertificateContext
  67. #define CertStoreCreateCrl CertCreateCRLContext
  68. #define CertStoreDuplicateCrl CertDuplicateCRLContext
  69. #define CertStoreFreeCrl CertFreeCRLContext
  70. #define CertStoreSetCrlProperty CertSetCRLContextProperty
  71. #define CertStoreGetCrlProperty CertGetCRLContextProperty
  72. #define WinGetSystemCertificateStoreA CertOpenSystemStoreA
  73. #define WinGetSystemCertificateStoreW CertOpenSystemStoreW
  74. #define WinInsertCertificateA CertAddEncodedCertificateToSystemStoreA
  75. #define WinInsertCertificateW CertAddEncodedCertificateToSystemStoreW
  76. #define CertHelperCompareCert CertCompareCertificate
  77. #define CertHelperCompareCertName CertCompareCertificateName
  78. #define CertHelperCompareCertNameAttr CertIsRDNAttrsInCertificateName
  79. // Note parameters changed from PCRYPT_BIT_BLOB to PCERT_PUBLIC_KEY_INFO
  80. #define CertHelperComparePublicKey CertComparePublicKeyInfo
  81. #define CertComparePublicKeys CertComparePublicKeyInfo
  82. // Note CertCompareCertificateName takes a PCERT_NAME_BLOB, not a PCERT_INFO
  83. #define CertHelperIsIssuerOfSubjectCert CertCompareCertificateName
  84. #define CertHelperIsIssuerOfCrl CertCompareCertificateName
  85. // Note: PublicKey changed from a PCRYPT_BIT_BLOB to a PCERT_PUBLIC_KEY_INFO.
  86. #define CertHelperKeyVerifySignature CryptVerifyCertificateSignature
  87. #if 0
  88. BOOL
  89. WINAPI
  90. CertHelperVerifySignature(
  91. IN HCRYPTPROV hCryptProv,
  92. IN DWORD dwCertEncodingType,
  93. IN BYTE *pbEncoded,
  94. IN DWORD cbEncoded,
  95. IN PCERT_INFO pIssuerInfo
  96. );
  97. #else
  98. #define CertHelperVerifySignature(hCryptProv, dwCertEncodingType, \
  99. pbEncoded, cbEncoded, pIssuerInfo) \
  100. CryptVerifyCertificateSignature(hCryptProv, dwCertEncodingType, \
  101. pbEncoded, cbEncoded, &pIssuerInfo->SubjectPublicKeyInfo)
  102. #endif
  103. #define CertHelperDigestToBeSigned CryptHashToBeSigned
  104. // Added dwFlags to CrytptDigestCertificate and CryptHashPublicKeyInfo
  105. #define CertHelperComputeDigest CryptHashCertificate
  106. #define CertHelperDigestPublicKeyInfo CryptHashPublicKeyInfo
  107. // Note added HashAlgid and dwHashFlags parameters.
  108. // Switched the order of the dwKeySpec and dwCertEncodingType parameters.
  109. #define CertHelperSignToBeSigned CryptSignCertificate
  110. #define CryptSignCertificateContext CryptSignCertificate
  111. #define CertHelperVerifyCertTimeValidity CertVerifyTimeValidity
  112. #define CertHelperVerifyCrlTimeValidity CertVerifyCRLTimeValidity
  113. #define CertHelperVerifyValidityNesting CertVerifyValidityNesting
  114. #define CertHelperVerifyCertRevocation CertVerifyRevocation
  115. #define CryptVerifyRevocation CertVerifyRevocation
  116. #define CertHelperAlgIdToObjId CertAlgIdToOID
  117. #define CertHelperObjIdToAlgId CertOIDToAlgId
  118. #define CertHelperFindExtension CertFindExtension
  119. #define CertHelperFindAttribute CertFindAttribute
  120. #define CertHelperFindRDNAttr CertFindRDNAttr
  121. #define CertHelperGetIntendedKeyUsage CertGetIntendedKeyUsage
  122. // Added deCertEncodingType parameter, returns PCERT_PUBLIC_KEY_INFO instead
  123. // of PBYTE
  124. #define CertHelperGetPublicKey CryptExportPublicKeyInfo
  125. #define CertGetPublicKey CryptExportPublicKeyInfo
  126. #if 0
  127. BOOL
  128. WINAPI
  129. CertHelperCreatePublicKeyInfo(
  130. IN HCRYPTPROV hCryptProv,
  131. DWORD dwKeySpec, // AT_SIGNATURE | AT_KEYEXCHANGE
  132. OUT PCERT_PUBLIC_KEY_INFO pInfo,
  133. IN OUT DWORD *pcbInfo
  134. );
  135. #else
  136. #define CertHelperCreatePublicKeyInfo(hCryptProv, dwKeySpec, \
  137. pInfo, pcbInfo) \
  138. CryptExportPublicKeyInfo(hCryptProv, dwKeySpec, X509_ASN_ENCODING, \
  139. pInfo, pcbInfo)
  140. #endif
  141. #define CertHelperNameValueToStr CertRDNValueToStrA
  142. #define CertHelperNameValueToWStr CertRDNValueToStrW
  143. // For all the SCA_*_PARA: dwVersion has been changed to cbSize.
  144. // cbSize must be set to the sizeof(CRYPT_*_PARA) or else LastError
  145. // will be updated with E_INVALIDARG.
  146. typedef PFN_CRYPT_GET_SIGNER_CERTIFICATE PFN_SCA_VERIFY_SIGNER_POLICY;
  147. typedef CRYPT_SIGN_MESSAGE_PARA SCA_SIGN_PARA;
  148. typedef PCRYPT_SIGN_MESSAGE_PARA PSCA_SIGN_PARA;
  149. // Combined into single dwMsgAndCertEncodingType
  150. typedef CRYPT_VERIFY_MESSAGE_PARA SCA_VERIFY_PARA;
  151. typedef PCRYPT_VERIFY_MESSAGE_PARA PSCA_VERIFY_PARA;
  152. // Added EncryptionAlgid, dwEncryptionFlags
  153. typedef CRYPT_ENCRYPT_MESSAGE_PARA SCA_ENCRYPT_PARA;
  154. typedef PCRYPT_ENCRYPT_MESSAGE_PARA PSCA_ENCRYPT_PARA;
  155. // Combined into single dwMsgAndCertEncodingType
  156. typedef CRYPT_DECRYPT_MESSAGE_PARA SCA_DECRYPT_PARA;
  157. typedef PCRYPT_DECRYPT_MESSAGE_PARA PSCA_DECRYPT_PARA;
  158. // Added HashAlgid, dwHashFlags
  159. typedef CRYPT_HASH_MESSAGE_PARA SCA_DIGEST_PARA;
  160. typedef PCRYPT_HASH_MESSAGE_PARA PSCA_DIGEST_PARA;
  161. // Added dwKeySpec, HashAlgid, dwHashFlags. Combined into single
  162. // dwMsgAndCertEncodingType.
  163. typedef CRYPT_KEY_SIGN_MESSAGE_PARA SCA_NO_CERT_SIGN_PARA;
  164. typedef PCRYPT_KEY_SIGN_MESSAGE_PARA PSCA_NO_CERT_SIGN_PARA;
  165. typedef CRYPT_KEY_VERIFY_MESSAGE_PARA SCA_NO_CERT_VERIFY_PARA;
  166. typedef PCRYPT_KEY_VERIFY_MESSAGE_PARA PSCA_NO_CERT_VERIFY_PARA;
  167. #define SCAEncrypt CryptEncryptMessage
  168. #define SCADecrypt CryptDecryptMessage
  169. #define SCASign CryptSignMessage
  170. #define SCAVerifySignature CryptVerifyMessageSignature
  171. #define SCASignAndEncrypt CryptSignAndEncryptMessage
  172. #define SCADecryptAndVerifySignature CryptDecryptAndVerifyMessageSignature
  173. #define SCADigest CryptHashMessage
  174. #define SCAVerifyDigest CryptVerifyMessageHash
  175. #define SCANoCertSign CryptSignMessageWithKey
  176. #define SCANoCertVerifySignature CryptVerifyMessageSignatureWithKey
  177. #define SCAVerifyDetachedDigest CryptVerifyDetachedMessageHash
  178. #define SCAVerifyDetachedSignature CryptVerifyDetachedMessageSignature
  179. #define SETSCASignAndExEncrypt CryptSignAndExEncryptMessage
  180. #define SETSCAExDecryptAndVerifySignature CryptExDecryptAndVerifyMessageSignature
  181. #define SETSCAExEncrypt CryptExEncryptMessage
  182. #define SETSCAExDecrypt CryptExDecryptMessage
  183. // A Hack to get the old encode/decode APIs to work
  184. // Renamed the structure used for X509_CERT. Futhermore, the content of the
  185. // CERT_ENCODING structure has changed.
  186. typedef CERT_SIGNED_CONTENT_INFO CERT_ENCODING;
  187. typedef PCERT_SIGNED_CONTENT_INFO PCERT_ENCODING;
  188. // Content types
  189. #define CERT_CONTENT 1
  190. #define CRL_CONTENT 2
  191. #define CERT_REQUEST_CONTENT 3
  192. #if 0
  193. BOOL
  194. WINAPI
  195. CertEncodeToBeSigned(
  196. IN DWORD dwEncodingType,
  197. IN DWORD dwContentType,
  198. IN void *pvInfo,
  199. OUT BYTE *pbEncodedToBeSigned,
  200. IN OUT DWORD *pcbEncodedToBeSigned
  201. );
  202. #else
  203. #define CertEncodeToBeSigned(dwEncodingType, dwContentType, pvInfo, \
  204. pbEncodedToBeSigned, pcbEncodedToBeSigned) \
  205. CryptEncodeObject(dwEncodingType, \
  206. (dwContentType == CERT_CONTENT) ? X509_CERT_TO_BE_SIGNED : \
  207. ((dwContentType == CRL_CONTENT) ? X509_CERT_CRL_TO_BE_SIGNED : \
  208. X509_CERT_REQUEST_TO_BE_SIGNED), \
  209. pvInfo, pbEncodedToBeSigned, pcbEncodedToBeSigned)
  210. #endif
  211. #if 0
  212. BOOL
  213. WINAPI
  214. CertEncode(
  215. IN DWORD dwEncodingType,
  216. IN const BYTE *pbEncodedToBeSigned,
  217. IN DWORD cbEncodedToBeSigned,
  218. IN PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
  219. IN const BYTE *pbSignature,
  220. IN DWORD cbSignature,
  221. IN OPTIONAL void *pAdditionalInfo,
  222. OUT BYTE *pbEncoded,
  223. IN OUT DWORD *pcbEncoded
  224. );
  225. #else
  226. // You'll need to create and initialize a CERT_SIGNED_CONTENT_INFO data
  227. // structure initialized with the above information
  228. // You'll need to manually modify your code
  229. #define CertEncode(dwEncodingType, pbEncodedToBeSigned, cbEncodedToBeSigned, \
  230. pSignatureAlgorithm, pbSignature, cbSignature, pAdditionalInfo, \
  231. pbEncoded, pcbEncoded) \
  232. CryptEncodeObject(dwEncodingType, X509_CERT, &CertSignedContentInfo, \
  233. pbEncoded, pcbEncoded)
  234. #endif
  235. #if 0
  236. BOOL
  237. WINAPI
  238. CertDecodeToBeSigned(
  239. IN DWORD dwEncodingType,
  240. IN DWORD dwContentType,
  241. IN const BYTE *pbEncoded,
  242. IN DWORD cbEncoded,
  243. OUT void *pvInfo,
  244. IN OUT DWORD *pcbInfo
  245. );
  246. #else
  247. #define CertDecodeToBeSigned(dwEncodingType, dwContentType, \
  248. pbEncoded, cbEncoded, pvInfo, pcbInfo) \
  249. CryptDecodeObject(dwEncodingType, \
  250. (dwContentType == CERT_CONTENT) ? X509_CERT_TO_BE_SIGNED : \
  251. ((dwContentType == CRL_CONTENT) ? X509_CERT_CRL_TO_BE_SIGNED : \
  252. X509_CERT_REQUEST_TO_BE_SIGNED), \
  253. pbEncoded, cbEncoded, 0, pvInfo, pcbInfo)
  254. #endif
  255. #if 0
  256. BOOL
  257. WINAPI
  258. CertDecode(
  259. IN DWORD dwEncodingType,
  260. IN const BYTE *pbEncoded,
  261. IN DWORD cbEncoded,
  262. OUT OPTIONAL PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
  263. IN OUT OPTIONAL DWORD *pcbSignatureAlgorithm,
  264. IN OUT OPTIONAL BYTE **ppbSignature,
  265. IN OUT OPTIONAL DWORD *pcbSignature,
  266. IN OUT BYTE **ppbEncodedToBeSigned,
  267. IN OUT DWORD *pcbEncodedToBeSigned,
  268. IN OUT OPTIONAL void *pAdditionalInfo,
  269. IN OUT OPTIONAL DWORD *pcbAdditionalInfo
  270. );
  271. #else
  272. // Returns a CERT_SIGNED_CONTENT_INFO data
  273. // structure containing the above information
  274. // You'll need to manually modify your code
  275. #define CertDecode(dwEncodingType, pbEncoded, cbEncoded, \
  276. pSignatureAlgorithm, pcbSignatureAlgorithm, \
  277. ppbSignature, pcbSignature, \
  278. ppbEncodedToBeSigned, pcbEncodedToBeSigned, \
  279. pAdditionalInfo, pcbAdditionalInfo) \
  280. CryptDecodeObject(dwEncodingType, X509_CERT, pbEncoded, cbEncoded, 0, \
  281. pCertSignedContentInfo, &cbCertSignedContentInfo)
  282. #endif
  283. #if 0
  284. BOOL
  285. WINAPI
  286. CertEncodeName(
  287. IN DWORD dwEncodingType,
  288. IN PCERT_NAME_INFO pInfo,
  289. OUT BYTE *pbEncoded,
  290. IN OUT DWORD *pcbEncoded
  291. );
  292. #else
  293. #define CertEncodeName(dwEncodingType, pInfo, \
  294. pbEncoded, pcbEncoded) \
  295. CryptEncodeObject(dwEncodingType, X509_NAME, \
  296. pInfo, pbEncoded, pcbEncoded)
  297. #endif
  298. #if 0
  299. BOOL
  300. WINAPI
  301. CertDecodeName(
  302. IN DWORD dwEncodingType,
  303. IN const BYTE *pbEncoded,
  304. IN DWORD cbEncoded,
  305. OUT PCERT_NAME_INFO pInfo,
  306. IN OUT DWORD *pcbInfo
  307. );
  308. #else
  309. #define CertDecodeName(dwEncodingType, pbEncoded, cbEncoded, \
  310. pInfo, pcbInfo) \
  311. CryptDecodeObject(dwEncodingType, X509_NAME, \
  312. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  313. #endif
  314. #if 0
  315. BOOL
  316. WINAPI
  317. CertEncodeNameValue(
  318. IN DWORD dwEncodingType,
  319. IN PCERT_NAME_VALUE pInfo,
  320. OUT BYTE *pbEncoded,
  321. IN OUT DWORD *pcbEncoded
  322. );
  323. #else
  324. #define CertEncodeNameValue(dwEncodingType, pInfo, \
  325. pbEncoded, pcbEncoded) \
  326. CryptEncodeObject(dwEncodingType, X509_NAME_VALUE, \
  327. pInfo, pbEncoded, pcbEncoded)
  328. #endif
  329. #if 0
  330. BOOL
  331. WINAPI
  332. CertDecodeNameValue(
  333. IN DWORD dwEncodingType,
  334. IN const BYTE *pbEncoded,
  335. IN DWORD cbEncoded,
  336. OUT PCERT_NAME_VALUE pInfo,
  337. IN OUT DWORD *pcbInfo
  338. );
  339. #else
  340. #define CertDecodeNameValue(dwEncodingType, pbEncoded, cbEncoded, \
  341. pInfo, pcbInfo) \
  342. CryptDecodeObject(dwEncodingType, X509_NAME_VALUE, \
  343. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  344. #endif
  345. #if 0
  346. BOOL
  347. WINAPI
  348. CertEncodeExtensions(
  349. IN DWORD dwEncodingType,
  350. IN PCERT_EXTENSIONS pInfo,
  351. OUT BYTE *pbEncoded,
  352. IN OUT DWORD *pcbEncoded
  353. );
  354. #else
  355. #define CertEncodeExtensions(dwEncodingType, pInfo, \
  356. pbEncoded, pcbEncoded) \
  357. CryptEncodeObject(dwEncodingType, X509_EXTENSIONS, \
  358. pInfo, pbEncoded, pcbEncoded)
  359. #endif
  360. #if 0
  361. BOOL
  362. WINAPI
  363. CertDecodeExtensions(
  364. IN DWORD dwEncodingType,
  365. IN const BYTE *pbEncoded,
  366. IN DWORD cbEncoded,
  367. OUT PCERT_EXTENSIONS pInfo,
  368. IN OUT DWORD *pcbInfo
  369. );
  370. #else
  371. #define CertDecodeExtensions(dwEncodingType, pbEncoded, cbEncoded, \
  372. pInfo, pcbInfo) \
  373. CryptDecodeObject(dwEncodingType, X509_EXTENSIONS, \
  374. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  375. #endif
  376. #if 0
  377. BOOL
  378. WINAPI
  379. PublicKeyInfoEncode(
  380. IN DWORD dwEncodingType,
  381. IN PCERT_PUBLIC_KEY_INFO pInfo,
  382. OUT BYTE *pbEncoded,
  383. IN OUT DWORD *pcbEncoded
  384. );
  385. #else
  386. #define PublicKeyInfoEncode(dwEncodingType, pInfo, \
  387. pbEncoded, pcbEncoded) \
  388. CryptEncodeObject(dwEncodingType, X509_PUBLIC_KEY_INFO, \
  389. pInfo, pbEncoded, pcbEncoded)
  390. #endif
  391. #if 0
  392. BOOL
  393. WINAPI
  394. PublicKeyInfoDecode(
  395. IN DWORD dwEncodingType,
  396. IN const BYTE *pbEncoded,
  397. IN DWORD cbEncoded,
  398. OUT PCERT_PUBLIC_KEY_INFO pInfo,
  399. IN OUT DWORD *pcbInfo
  400. );
  401. #else
  402. #define PublicKeyInfoDecode(dwEncodingType, pbEncoded, cbEncoded, \
  403. pInfo, pcbInfo) \
  404. CryptDecodeObject(dwEncodingType, X509_PUBLIC_KEY_INFO, \
  405. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  406. #endif
  407. #if 0
  408. BOOL
  409. WINAPI
  410. AuthorityKeyIdEncode(
  411. IN DWORD dwEncodingType,
  412. IN PCERT_AUTHORITY_KEY_ID_INFO pInfo,
  413. OUT BYTE *pbEncoded,
  414. IN OUT DWORD *pcbEncoded
  415. );
  416. #else
  417. #define AuthorityKeyIdEncode(dwEncodingType, pInfo, \
  418. pbEncoded, pcbEncoded) \
  419. CryptEncodeObject(dwEncodingType, X509_AUTHORITY_KEY_ID, \
  420. pInfo, pbEncoded, pcbEncoded)
  421. #endif
  422. #if 0
  423. BOOL
  424. WINAPI
  425. AuthorityKeyIdDecode(
  426. IN DWORD dwEncodingType,
  427. IN const BYTE *pbEncoded,
  428. IN DWORD cbEncoded,
  429. OUT PCERT_AUTHORITY_KEY_ID_INFO pInfo,
  430. IN OUT DWORD *pcbInfo
  431. );
  432. #else
  433. #define AuthorityKeyIdDecode(dwEncodingType, pbEncoded, cbEncoded, \
  434. pInfo, pcbInfo) \
  435. CryptDecodeObject(dwEncodingType, X509_AUTHORITY_KEY_ID, \
  436. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  437. #endif
  438. #if 0
  439. BOOL
  440. WINAPI
  441. KeyAttributesEncode(
  442. IN DWORD dwEncodingType,
  443. IN PCERT_KEY_ATTRIBUTES_INFO pInfo,
  444. OUT BYTE *pbEncoded,
  445. IN OUT DWORD *pcbEncoded
  446. );
  447. #else
  448. #define KeyAttributesEncode(dwEncodingType, pInfo, \
  449. pbEncoded, pcbEncoded) \
  450. CryptEncodeObject(dwEncodingType, X509_KEY_ATTRIBUTES, \
  451. pInfo, pbEncoded, pcbEncoded)
  452. #endif
  453. #if 0
  454. BOOL
  455. WINAPI
  456. KeyAttributesDecode(
  457. IN DWORD dwEncodingType,
  458. IN const BYTE *pbEncoded,
  459. IN DWORD cbEncoded,
  460. OUT PCERT_KEY_ATTRIBUTES_INFO pInfo,
  461. IN OUT DWORD *pcbInfo
  462. );
  463. #else
  464. #define KeyAttributesDecode(dwEncodingType, pbEncoded, cbEncoded, \
  465. pInfo, pcbInfo) \
  466. CryptDecodeObject(dwEncodingType, X509_KEY_ATTRIBUTES, \
  467. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  468. #endif
  469. #if 0
  470. BOOL
  471. WINAPI
  472. KeyUsageRestrictionEncode(
  473. IN DWORD dwEncodingType,
  474. IN PCERT_KEY_USAGE_RESTRICTION_INFO pInfo,
  475. OUT BYTE *pbEncoded,
  476. IN OUT DWORD *pcbEncoded
  477. );
  478. #else
  479. #define KeyUsageRestrictionEncode(dwEncodingType, pInfo, \
  480. pbEncoded, pcbEncoded) \
  481. CryptEncodeObject(dwEncodingType, X509_KEY_USAGE_RESTRICTION, \
  482. pInfo, pbEncoded, pcbEncoded)
  483. #endif
  484. #if 0
  485. BOOL
  486. WINAPI
  487. KeyUsageRestrictionDecode(
  488. IN DWORD dwEncodingType,
  489. IN const BYTE *pbEncoded,
  490. IN DWORD cbEncoded,
  491. OUT PCERT_KEY_USAGE_RESTRICTION_INFO pInfo,
  492. IN OUT DWORD *pcbInfo
  493. );
  494. #else
  495. #define KeyUsageRestrictionDecode(dwEncodingType, pbEncoded, cbEncoded, \
  496. pInfo, pcbInfo) \
  497. CryptDecodeObject(dwEncodingType, X509_KEY_USAGE_RESTRICTION, \
  498. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  499. #endif
  500. #if 0
  501. BOOL
  502. WINAPI
  503. AltNameEncode(
  504. IN DWORD dwEncodingType,
  505. IN PCERT_ALT_NAME_INFO pInfo,
  506. OUT BYTE *pbEncoded,
  507. IN OUT DWORD *pcbEncoded
  508. );
  509. #else
  510. #define AltNameEncode(dwEncodingType, pInfo, \
  511. pbEncoded, pcbEncoded) \
  512. CryptEncodeObject(dwEncodingType, X509_ALTERNATE_NAME, \
  513. pInfo, pbEncoded, pcbEncoded)
  514. #endif
  515. #if 0
  516. BOOL
  517. WINAPI
  518. AltNameDecode(
  519. IN DWORD dwEncodingType,
  520. IN const BYTE *pbEncoded,
  521. IN DWORD cbEncoded,
  522. OUT PCERT_ALT_NAME_INFO pInfo,
  523. IN OUT DWORD *pcbInfo
  524. );
  525. #else
  526. #define AltNameDecode(dwEncodingType, pbEncoded, cbEncoded, \
  527. pInfo, pcbInfo) \
  528. CryptDecodeObject(dwEncodingType, X509_ALTERNATE_NAME, \
  529. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  530. #endif
  531. #if 0
  532. BOOL
  533. WINAPI
  534. BasicConstraintsEncode(
  535. IN DWORD dwEncodingType,
  536. IN PCERT_BASIC_CONSTRAINTS_INFO pInfo,
  537. OUT BYTE *pbEncoded,
  538. IN OUT DWORD *pcbEncoded
  539. );
  540. #else
  541. #define BasicConstraintsEncode(dwEncodingType, pInfo, \
  542. pbEncoded, pcbEncoded) \
  543. CryptEncodeObject(dwEncodingType, X509_BASIC_CONSTRAINTS, \
  544. pInfo, pbEncoded, pcbEncoded)
  545. #endif
  546. #if 0
  547. BOOL
  548. WINAPI
  549. BasicConstraintsDecode(
  550. IN DWORD dwEncodingType,
  551. IN const BYTE *pbEncoded,
  552. IN DWORD cbEncoded,
  553. OUT PCERT_BASIC_CONSTRAINTS_INFO pInfo,
  554. IN OUT DWORD *pcbInfo
  555. );
  556. #else
  557. #define BasicConstraintsDecode(dwEncodingType, pbEncoded, cbEncoded, \
  558. pInfo, pcbInfo) \
  559. CryptDecodeObject(dwEncodingType, X509_BASIC_CONSTRAINTS, \
  560. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  561. #endif
  562. #if 0
  563. BOOL
  564. WINAPI
  565. SETAccountAliasEncode(
  566. IN DWORD dwEncodingType,
  567. IN BOOL *pbInfo,
  568. OUT BYTE *pbEncoded,
  569. IN OUT DWORD *pcbEncoded
  570. );
  571. #else
  572. #define SETAccountAliasEncode(dwEncodingType, pInfo, \
  573. pbEncoded, pcbEncoded) \
  574. CryptEncodeObject(dwEncodingType, X509_SET_ACCOUNT_ALIAS, \
  575. pInfo, pbEncoded, pcbEncoded)
  576. #endif
  577. #if 0
  578. BOOL
  579. WINAPI
  580. SETAccountAliasDecode(
  581. IN DWORD dwEncodingType,
  582. IN const BYTE *pbEncoded,
  583. IN DWORD cbEncoded,
  584. OUT BOOL *pbInfo,
  585. IN OUT DWORD *pcbInfo
  586. );
  587. #else
  588. #define SETAccountAliasDecode(dwEncodingType, pbEncoded, cbEncoded, \
  589. pInfo, pcbInfo) \
  590. CryptDecodeObject(dwEncodingType, X509_SET_ACCOUNT_ALIAS, \
  591. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  592. #endif
  593. #if 0
  594. BOOL
  595. WINAPI
  596. SETHashedRootKeyEncode(
  597. IN DWORD dwEncodingType,
  598. IN BYTE rgbInfo[SET_HASHED_ROOT_LEN],
  599. OUT BYTE *pbEncoded,
  600. IN OUT DWORD *pcbEncoded
  601. );
  602. #else
  603. #define SETHashedRootKeyEncode(dwEncodingType, pInfo, \
  604. pbEncoded, pcbEncoded) \
  605. CryptEncodeObject(dwEncodingType, X509_SET_HASHED_ROOT_KEY, \
  606. pInfo, pbEncoded, pcbEncoded)
  607. #endif
  608. #if 0
  609. BOOL
  610. WINAPI
  611. SETHashedRootKeyDecode(
  612. IN DWORD dwEncodingType,
  613. IN const BYTE *pbEncoded,
  614. IN DWORD cbEncoded,
  615. OUT BYTE rgbInfo[SET_HASHED_ROOT_LEN],
  616. IN OUT DWORD *pcbInfo
  617. );
  618. #else
  619. #define SETHashedRootKeyDecode(dwEncodingType, pbEncoded, cbEncoded, \
  620. pInfo, pcbInfo) \
  621. CryptDecodeObject(dwEncodingType, X509_SET_HASHED_ROOT_KEY, \
  622. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  623. #endif
  624. #if 0
  625. BOOL
  626. WINAPI
  627. SETCertificateTypeEncode(
  628. IN DWORD dwEncodingType,
  629. IN PCRYPT_BIT_BLOB pInfo,
  630. OUT BYTE *pbEncoded,
  631. IN OUT DWORD *pcbEncoded
  632. );
  633. #else
  634. #define SETCertificateTypeEncode(dwEncodingType, pInfo, \
  635. pbEncoded, pcbEncoded) \
  636. CryptEncodeObject(dwEncodingType, X509_SET_CERTIFICATE_TYPE, \
  637. pInfo, pbEncoded, pcbEncoded)
  638. #endif
  639. #if 0
  640. BOOL
  641. WINAPI
  642. SETCertificateTypeDecode(
  643. IN DWORD dwEncodingType,
  644. IN const BYTE *pbEncoded,
  645. IN DWORD cbEncoded,
  646. OUT PCRYPT_BIT_BLOB pInfo,
  647. IN OUT DWORD *pcbInfo
  648. );
  649. #else
  650. #define SETCertificateTypeDecode(dwEncodingType, pbEncoded, cbEncoded, \
  651. pInfo, pcbInfo) \
  652. CryptDecodeObject(dwEncodingType, X509_SET_CERTIFICATE_TYPE, \
  653. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  654. #endif
  655. #if 0
  656. BOOL
  657. WINAPI
  658. SETMerchantDataEncode(
  659. IN DWORD dwEncodingType,
  660. IN PSET_MERCHANT_DATA_INFO pInfo,
  661. OUT BYTE *pbEncoded,
  662. IN OUT DWORD *pcbEncoded
  663. );
  664. #else
  665. #define SETMerchantDataEncode(dwEncodingType, pInfo, \
  666. pbEncoded, pcbEncoded) \
  667. CryptEncodeObject(dwEncodingType, X509_SET_MERCHANT_DATA, \
  668. pInfo, pbEncoded, pcbEncoded)
  669. #endif
  670. #if 0
  671. BOOL
  672. WINAPI
  673. SETMerchantDataDecode(
  674. IN DWORD dwEncodingType,
  675. IN const BYTE *pbEncoded,
  676. IN DWORD cbEncoded,
  677. OUT PSET_MERCHANT_DATA_INFO pInfo,
  678. IN OUT DWORD *pcbInfo
  679. );
  680. #else
  681. #define SETMerchantDataDecode(dwEncodingType, pbEncoded, cbEncoded, \
  682. pInfo, pcbInfo) \
  683. CryptDecodeObject(dwEncodingType, X509_SET_MERCHANT_DATA, \
  684. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  685. #endif
  686. // A Hack to get the old SPC encode/decode APIs to work
  687. #if 0
  688. BOOL
  689. WINAPI
  690. SpcSpAgencyInfoEncode(
  691. IN DWORD dwEncodingType,
  692. IN PSPC_SP_AGENCY_INFO pInfo,
  693. OUT BYTE *pbEncoded,
  694. IN OUT DWORD *pcbEncoded
  695. );
  696. BOOL
  697. WINAPI
  698. SpcSpAgencyInfoDecode(
  699. IN DWORD dwEncodingType,
  700. IN const BYTE *pbEncoded,
  701. IN DWORD cbEncoded,
  702. OUT PSPC_SP_AGENCY_INFO pInfo,
  703. IN OUT DWORD *pcbInfo
  704. );
  705. #else
  706. #define SpcSpAgencyInfoEncode(dwEncodingType, pInfo, \
  707. pbEncoded, pcbEncoded) \
  708. CryptEncodeObject(dwEncodingType, SPC_SP_AGENCY_INFO_STRUCT, \
  709. pInfo, pbEncoded, pcbEncoded)
  710. #define SpcSpAgencyInfoDecode(dwEncodingType, pbEncoded, cbEncoded, \
  711. pInfo, pcbInfo) \
  712. CryptDecodeObject(dwEncodingType, SPC_SP_AGENCY_INFO_STRUCT, \
  713. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  714. #endif
  715. #if 0
  716. BOOL
  717. WINAPI
  718. SpcMinimalCriteriaInfoEncode(
  719. IN DWORD dwEncodingType,
  720. IN BOOL *pInfo,
  721. OUT BYTE *pbEncoded,
  722. IN OUT DWORD *pcbEncoded
  723. );
  724. BOOL
  725. WINAPI
  726. SpcMinimalCriteriaInfoDecode(
  727. IN DWORD dwEncodingType,
  728. IN const BYTE *pbEncoded,
  729. IN DWORD cbEncoded,
  730. OUT BOOL *pInfo,
  731. IN OUT DWORD *pcbInfo
  732. );
  733. #else
  734. #define SpcMinimalCriteriaInfoEncode(dwEncodingType, pInfo, \
  735. pbEncoded, pcbEncoded) \
  736. CryptEncodeObject(dwEncodingType, SPC_MINIMAL_CRITERIA_STRUCT, \
  737. pInfo, pbEncoded, pcbEncoded)
  738. #define SpcMinimalCriteriaInfoDecode(dwEncodingType, pbEncoded, cbEncoded, \
  739. pInfo, pcbInfo) \
  740. CryptDecodeObject(dwEncodingType, SPC_MINIMAL_CRITERIA_STRUCT, \
  741. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  742. #endif
  743. #if 0
  744. BOOL
  745. WINAPI
  746. SpcFinancialCriteriaInfoEncode(
  747. IN DWORD dwEncodingType,
  748. IN PSPC_FINANCIAL_CRITERIA pInfo,
  749. OUT BYTE *pbEncoded,
  750. IN OUT DWORD *pcbEncoded
  751. );
  752. BOOL
  753. WINAPI
  754. SpcFinancialCriteriaInfoDecode(
  755. IN DWORD dwEncodingType,
  756. IN const BYTE *pbEncoded,
  757. IN DWORD cbEncoded,
  758. OUT PSPC_FINANCIAL_CRITERIA pInfo,
  759. IN OUT DWORD *pcbInfo
  760. );
  761. #else
  762. #define SpcFinancialCriteriaInfoEncode(dwEncodingType, pInfo, \
  763. pbEncoded, pcbEncoded) \
  764. CryptEncodeObject(dwEncodingType, SPC_FINANCIAL_CRITERIA_STRUCT, \
  765. pInfo, pbEncoded, pcbEncoded)
  766. #define SpcFinancialCriteriaInfoDecode(dwEncodingType, pbEncoded, cbEncoded, \
  767. pInfo, pcbInfo) \
  768. CryptDecodeObject(dwEncodingType, SPC_FINANCIAL_CRITERIA_STRUCT, \
  769. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  770. #endif
  771. #if 0
  772. BOOL
  773. WINAPI
  774. SpcIndirectDataContentEncode(
  775. IN DWORD dwEncodingType,
  776. IN PSPC_INDIRECT_DATA_CONTENT pInfo,
  777. OUT BYTE *pbEncoded,
  778. IN OUT DWORD *pcbEncoded
  779. );
  780. BOOL
  781. WINAPI
  782. SpcIndirectDataContentDecode(
  783. IN DWORD dwEncodingType,
  784. IN const BYTE *pbEncoded,
  785. IN DWORD cbEncoded,
  786. OUT PSPC_INDIRECT_DATA_CONTENT pInfo,
  787. IN OUT DWORD *pcbInfo
  788. );
  789. #else
  790. #define SpcIndirectDataContentEncode(dwEncodingType, pInfo, \
  791. pbEncoded, pcbEncoded) \
  792. CryptEncodeObject(dwEncodingType, SPC_INDIRECT_DATA_CONTENT_STRUCT, \
  793. pInfo, pbEncoded, pcbEncoded)
  794. #define SpcIndirectDataContentDecode(dwEncodingType, pbEncoded, cbEncoded, \
  795. pInfo, pcbInfo) \
  796. CryptDecodeObject(dwEncodingType, SPC_INDIRECT_DATA_CONTENT_STRUCT, \
  797. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  798. #endif
  799. #if 0
  800. BOOL
  801. WINAPI
  802. SpcPeImageDataEncode(
  803. IN DWORD dwEncodingType,
  804. IN PSPC_PE_IMAGE_DATA pInfo,
  805. OUT BYTE *pbEncoded,
  806. IN OUT DWORD *pcbEncoded
  807. );
  808. BOOL
  809. WINAPI
  810. SpcPeImageDataDecode(
  811. IN DWORD dwEncodingType,
  812. IN const BYTE *pbEncoded,
  813. IN DWORD cbEncoded,
  814. OUT PSPC_PE_IMAGE_DATA pInfo,
  815. IN OUT DWORD *pcbInfo
  816. );
  817. #else
  818. #define SpcPeImageDataEncode(dwEncodingType, pInfo, \
  819. pbEncoded, pcbEncoded) \
  820. CryptEncodeObject(dwEncodingType, SPC_PE_IMAGE_DATA_STRUCT, \
  821. pInfo, pbEncoded, pcbEncoded)
  822. #define SpcPeImageDataDecode(dwEncodingType, pbEncoded, cbEncoded, \
  823. pInfo, pcbInfo) \
  824. CryptDecodeObject(dwEncodingType, SPC_PE_IMAGE_DATA_STRUCT, \
  825. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  826. #endif
  827. #if 0
  828. BOOL
  829. WINAPI
  830. SpcLinkEncode(
  831. IN DWORD dwEncodingType,
  832. IN PSPC_LINK pInfo,
  833. OUT BYTE *pbEncoded,
  834. IN OUT DWORD *pcbEncoded
  835. );
  836. BOOL
  837. WINAPI
  838. SpcLinkDecode(
  839. IN DWORD dwEncodingType,
  840. IN const BYTE *pbEncoded,
  841. IN DWORD cbEncoded,
  842. OUT PSPC_LINK pInfo,
  843. IN OUT DWORD *pcbInfo
  844. );
  845. #else
  846. #define SpcLinkEncode(dwEncodingType, pInfo, \
  847. pbEncoded, pcbEncoded) \
  848. CryptEncodeObject(dwEncodingType, SPC_LINK_STRUCT, \
  849. pInfo, pbEncoded, pcbEncoded)
  850. #define SpcLinkDecode(dwEncodingType, pbEncoded, cbEncoded, \
  851. pInfo, pcbInfo) \
  852. CryptDecodeObject(dwEncodingType, SPC_LINK_STRUCT, \
  853. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  854. #endif
  855. #if 0
  856. BOOL
  857. WINAPI
  858. SpcStatementTypeEncode(
  859. IN DWORD dwEncodingType,
  860. IN PSPC_STATEMENT_TYPE pInfo,
  861. OUT BYTE *pbEncoded,
  862. IN OUT DWORD *pcbEncoded
  863. );
  864. BOOL
  865. WINAPI
  866. SpcStatementTypeDecode(
  867. IN DWORD dwEncodingType,
  868. IN const BYTE *pbEncoded,
  869. IN DWORD cbEncoded,
  870. OUT PSPC_STATEMENT_TYPE pInfo,
  871. IN OUT DWORD *pcbInfo
  872. );
  873. #else
  874. #define SpcStatementTypeEncode(dwEncodingType, pInfo, \
  875. pbEncoded, pcbEncoded) \
  876. CryptEncodeObject(dwEncodingType, SPC_STATEMENT_TYPE_STRUCT, \
  877. pInfo, pbEncoded, pcbEncoded)
  878. #define SpcStatementTypeDecode(dwEncodingType, pbEncoded, cbEncoded, \
  879. pInfo, pcbInfo) \
  880. CryptDecodeObject(dwEncodingType, SPC_STATEMENT_TYPE_STRUCT, \
  881. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  882. #endif
  883. #if 0
  884. BOOL
  885. WINAPI
  886. SpcSpOpusInfoEncode(
  887. IN DWORD dwEncodingType,
  888. IN PSPC_SP_OPUS_INFO pInfo,
  889. OUT BYTE *pbEncoded,
  890. IN OUT DWORD *pcbEncoded
  891. );
  892. BOOL
  893. WINAPI
  894. SpcSpOpusInfoDecode(
  895. IN DWORD dwEncodingType,
  896. IN const BYTE *pbEncoded,
  897. IN DWORD cbEncoded,
  898. OUT PSPC_SP_OPUS_INFO pInfo,
  899. IN OUT DWORD *pcbInfo
  900. );
  901. #else
  902. #define SpcSpOpusInfoEncode(dwEncodingType, pInfo, \
  903. pbEncoded, pcbEncoded) \
  904. CryptEncodeObject(dwEncodingType, SPC_SP_OPUS_INFO_STRUCT, \
  905. pInfo, pbEncoded, pcbEncoded)
  906. #define SpcSpOpusInfoDecode(dwEncodingType, pbEncoded, cbEncoded, \
  907. pInfo, pcbInfo) \
  908. CryptDecodeObject(dwEncodingType, SPC_SP_OPUS_INFO_STRUCT, \
  909. pbEncoded, cbEncoded, 0, pInfo, pcbInfo)
  910. #endif
  911. #ifdef __cplusplus
  912. } // Balance extern "C" above
  913. #endif
  914. #endif /* _WIN32_WINNT >= 0x0400 */
  915. #endif // __CNVCRYPT_H__