VirtualBox

Changeset 100442 in vbox for trunk/include


Ignore:
Timestamp:
Jul 8, 2023 11:10:51 AM (18 months ago)
Author:
vboxsync
Message:

IPRT,OpenSSL: Support ECDSA for verficiation purposes when IPRT links with OpenSSL. This required quite a bit of cleanups, so not entirely no-risk. bugref:10479 ticketref:21621

Location:
trunk/include/iprt
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/crypto/key.h

    r98103 r100442  
    6666    /** RSA public key. */
    6767    RTCRKEYTYPE_RSA_PUBLIC,
     68    /** ECDSA private key. */
     69    RTCRKEYTYPE_ECDSA_PRIVATE,
     70    /** ECDSA public key. */
     71    RTCRKEYTYPE_ECDSA_PUBLIC,
    6872    /** End of key types. */
    6973    RTCRKEYTYPE_END,
     
    7579RTDECL(int)             RTCrKeyCreateFromSubjectPublicKeyInfo(PRTCRKEY phKey, struct RTCRX509SUBJECTPUBLICKEYINFO const *pSrc,
    7680                                                              PRTERRINFO pErrInfo, const char *pszErrorTag);
    77 RTDECL(int)             RTCrKeyCreateFromPublicAlgorithmAndBits(PRTCRKEY phKey,  PCRTASN1OBJID pAlgorithm,
    78                                                                 PCRTASN1BITSTRING pPublicKey,
     81RTDECL(int)             RTCrKeyCreateFromPublicAlgorithmAndBits(PRTCRKEY phKey, PCRTASN1OBJID pAlgorithm,
     82                                                                PCRTASN1DYNTYPE pParameters, PCRTASN1BITSTRING pPublicKey,
    7983                                                                PRTERRINFO pErrInfo, const char *pszErrorTag);
    8084RTDECL(int)             RTCrKeyCreateFromPemSection(PRTCRKEY phKey, uint32_t fFlags, struct RTCRPEMSECTION const *pSection,
     
    105109RTDECL(int)             RTCrKeyQueryRsaModulus(RTCRKEY hKey, PRTBIGNUM pModulus);
    106110RTDECL(int)             RTCrKeyQueryRsaPrivateExponent(RTCRKEY hKey, PRTBIGNUM pPrivateExponent);
     111RTDECL(int)             RTCrKeyVerifyParameterCompatibility(RTCRKEY hKey, PCRTASN1DYNTYPE pParameters, bool fForSignature,
     112                                                            PCRTASN1OBJID pAlgorithm, PRTERRINFO pErrInfo);
     113
    107114
    108115/** Public key markers. */
  • trunk/include/iprt/crypto/pkix.h

    r98103 r100442  
    6060 * @param   pAlgorithm      The signature algorithm (digest w/ cipher).
    6161 * @param   hPublicKey      The public key.
    62  * @param   pParameters     Parameter to the public key algorithm. Optional.
     62 * @param   pParameters     The signature parameters (not key, those are already
     63 *                          kept by hPublicKey).
    6364 * @param   pSignatureValue The signature value.
    6465 * @param   pvData          The signed data.
     
    8182 * @param   pAlgorithm      The signature algorithm (digest w/ cipher).
    8283 * @param   hPublicKey      The public key.
    83  * @param   pParameters     Parameter to the public key algorithm. Optional.
     84 * @param   pParameters     The signature parameters (not key, those are already
     85 *                          kept by hPublicKey).
    8486 * @param   pvSignedDigest  The signed digest.
    8587 * @param   cbSignedDigest  The signed digest size.
     
    146148 *
    147149 * @returns Cipher OID string on success, NULL on failure.
    148  * @param   pAlgorithm      The signature algorithm (digest w/ cipher).
     150 * @param   pAlgorithm          The signature algorithm (hash function w/ cipher).
     151 * @sa      RTCrX509AlgorithmIdentifier_GetEncryptionOid,
     152 *          RTCrX509AlgorithmIdentifier_GetEncryptionOidFromOid
    149153 */
    150154RTDECL(const char *) RTCrPkixGetCiperOidFromSignatureAlgorithm(PCRTASN1OBJID pAlgorithm);
     155
     156/**
     157 * Gets the cipher OID matching the given signature algorithm OID.
     158 *
     159 * @returns Cipher OID string on success, NULL on failure.
     160 * @param   pszSignatureOid     The signature algorithm ID (hash function w/ cipher).
     161 * @sa      RTCrX509AlgorithmIdentifier_GetEncryptionOid,
     162 *          RTCrX509AlgorithmIdentifier_GetEncryptionOidFromOid
     163 */
     164RTDECL(const char *) RTCrPkixGetCiperOidFromSignatureAlgorithmOid(const char *pszSignatureOid);
    151165
    152166
     
    170184#define RTCR_PKCS1_SHA512T224_WITH_RSA_OID          "1.2.840.113549.1.1.15"
    171185#define RTCR_PKCS1_SHA512T256_WITH_RSA_OID          "1.2.840.113549.1.1.16"
     186/** @} */
     187
     188/** @name ANSI X9.62 Object Identifiers (OIDs)
     189 * @{ */
     190#define RTCR_X962_ECDSA_OID                         "1.2.840.10045.2.1"
     191#define RTCR_X962_ECDSA_WITH_SHA1_OID               "1.2.840.10045.4.1"
     192#define RTCR_X962_ECDSA_WITH_SHA2_OID               "1.2.840.10045.4.3"
     193#define RTCR_X962_ECDSA_WITH_SHA224_OID             "1.2.840.10045.4.3.1"
     194#define RTCR_X962_ECDSA_WITH_SHA256_OID             "1.2.840.10045.4.3.2"
     195#define RTCR_X962_ECDSA_WITH_SHA384_OID             "1.2.840.10045.4.3.3"
     196#define RTCR_X962_ECDSA_WITH_SHA512_OID             "1.2.840.10045.4.3.4"
     197/** @}  */
     198
     199/** @name NIST Object Identifiers (OIDs)
     200 * @{ */
     201#define RTCR_NIST_ALGORITHM_OID                     "2.16.840.1.101.3.4"
     202#define RTCR_NIST_HASH_ALGS_OID                     "2.16.840.1.101.3.4.2"
     203#define RTCR_NIST_SIG_ALGS_OID                      "2.16.840.1.101.3.4.3"
     204#define RTCR_NIST_SHA3_224_WITH_ECDSA_OID           "2.16.840.1.101.3.4.3.9"
     205#define RTCR_NIST_SHA3_256_WITH_ECDSA_OID           "2.16.840.1.101.3.4.3.10"
     206#define RTCR_NIST_SHA3_384_WITH_ECDSA_OID           "2.16.840.1.101.3.4.3.11"
     207#define RTCR_NIST_SHA3_512_WITH_ECDSA_OID           "2.16.840.1.101.3.4.3.12"
     208#define RTCR_NIST_SHA3_224_WITH_RSA_OID             "2.16.840.1.101.3.4.3.13"
     209#define RTCR_NIST_SHA3_256_WITH_RSA_OID             "2.16.840.1.101.3.4.3.14"
     210#define RTCR_NIST_SHA3_384_WITH_RSA_OID             "2.16.840.1.101.3.4.3.15"
     211#define RTCR_NIST_SHA3_512_WITH_RSA_OID             "2.16.840.1.101.3.4.3.16"
    172212/** @}  */
    173213
     
    300340 * @param   ppvOpaque   Where to store an opaque schema parameter. Optional.
    301341 */
    302 PCRTCRPKIXSIGNATUREDESC RTCrPkixSignatureFindByObjIdString(const char *pszObjId, void *ppvOpaque);
     342PCRTCRPKIXSIGNATUREDESC RTCrPkixSignatureFindByObjIdString(const char *pszObjId, void **ppvOpaque);
    303343
    304344/**
  • trunk/include/iprt/crypto/x509.h

    r98103 r100442  
    8181 *
    8282 * @returns Valid RTDIGESTTYPE on success, RTDIGESTTYPE_INVALID on failure.
    83  * @param   pThis           The IPRT representation of a X.509 algorithm
    84  *                          identifier object.
    85  */
    86 RTDECL(RTDIGESTTYPE) RTCrX509AlgorithmIdentifier_QueryDigestType(PCRTCRX509ALGORITHMIDENTIFIER pThis);
     83 * @param   pThis               The IPRT representation of a X.509 algorithm
     84 *                              identifier object.
     85 * @param   fPureDigestsOnly    Whether to only match IDs that only identify
     86 *                              digest algorithms, or whether to also include
     87 *                              IDs that mixes hash and encryption/whatever.
     88 */
     89RTDECL(RTDIGESTTYPE) RTCrX509AlgorithmIdentifier_GetDigestType(PCRTCRX509ALGORITHMIDENTIFIER pThis, bool fPureDigestsOnly);
    8790
    8891/**
     
    9093 *
    9194 * @returns The digest size in bytes, UINT32_MAX if unknown digest.
    92  * @param   pThis           The IPRT representation of a X.509 algorithm
    93  *                          identifier object.
    94  */
    95 RTDECL(uint32_t) RTCrX509AlgorithmIdentifier_QueryDigestSize(PCRTCRX509ALGORITHMIDENTIFIER pThis);
     95 * @param   pThis               The IPRT representation of a X.509 algorithm
     96 *                              identifier object.
     97 * @param   fPureDigestsOnly    Whether to only match IDs that only identify
     98 *                              digest algorithms, or whether to also include
     99 *                              IDs that mixes hash and encryption/whatever.
     100 */
     101RTDECL(uint32_t) RTCrX509AlgorithmIdentifier_GetDigestSize(PCRTCRX509ALGORITHMIDENTIFIER pThis, bool fPureDigestsOnly);
     102
     103/**
     104 * Tries to get the encryption OID from the algorithm.
     105 *
     106 * @returns The encryption (cipher) OID  on success, NULL on failure.
     107 * @param   pThis               The IPRT representation of a X.509 algorithm
     108 *                              identifier object.
     109 * @param   fMustIncludeHash    Whether the algorithm ID represented by @a pThis
     110 *                              must include a hash (true) or whether it is
     111 *                              okay to accept pure encryption IDs as well
     112 *                              (false).
     113 */
     114RTDECL(const char *) RTCrX509AlgorithmIdentifier_GetEncryptionOid(PCRTCRX509ALGORITHMIDENTIFIER pThis, bool fMustIncludeHash);
     115
     116/**
     117 * Tries to get the encryption OID from the given algorithm OID string.
     118 *
     119 * @returns The encryption (cipher) OID  on success, NULL on failure.
     120 * @param   pszAlgorithmOid     The IPRT representation of a X.509 algorithm
     121 *                              identifier object.
     122 * @param   fMustIncludeHash    Whether @a pszAlgorithmOid must include a hash
     123 *                              (true) or whether it is okay to accept pure
     124 *                              encryption IDs as well (false).
     125 */
     126RTDECL(const char *) RTCrX509AlgorithmIdentifier_GetEncryptionOidFromOid(const char *pszAlgorithmOid, bool fMustIncludeHash);
    96127
    97128RTDECL(int) RTCrX509AlgorithmIdentifier_CompareWithString(PCRTCRX509ALGORITHMIDENTIFIER pThis, const char *pszObjId);
     
    155186#define RTCRX509ALGORITHMIDENTIFIERID_MD4               "1.2.840.113549.2.4"
    156187#define RTCRX509ALGORITHMIDENTIFIERID_MD5               "1.2.840.113549.2.5"
     188#define RTCRX509ALGORITHMIDENTIFIERID_SHA0              "1.3.14.3.2.18"
    157189#define RTCRX509ALGORITHMIDENTIFIERID_SHA1              "1.3.14.3.2.26"
    158190#define RTCRX509ALGORITHMIDENTIFIERID_SHA256            "2.16.840.1.101.3.4.2.1"
     
    188220#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_384_WITH_RSA     "2.16.840.1.101.3.4.3.15"
    189221#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_512_WITH_RSA     "2.16.840.1.101.3.4.3.16"
     222#define RTCRX509ALGORITHMIDENTIFIERID_ECDSA                 "1.2.840.10045.2.1"
     223#define RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_ECDSA       "1.2.840.10045.4.1"
     224#define RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_ECDSA     "1.2.840.10045.4.3.1"
     225#define RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_ECDSA     "1.2.840.10045.4.3.2"
     226#define RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_ECDSA     "1.2.840.10045.4.3.3"
     227#define RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_ECDSA     "1.2.840.10045.4.3.4"
     228#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_224_WITH_ECDSA   "2.16.840.1.101.3.4.3.9"
     229#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_256_WITH_ECDSA   "2.16.840.1.101.3.4.3.10"
     230#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_384_WITH_ECDSA   "2.16.840.1.101.3.4.3.11"
     231#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_512_WITH_ECDSA   "2.16.840.1.101.3.4.3.12"
    190232/** @} */
    191233
  • trunk/include/iprt/err.h

    r100029 r100442  
    21702170/** Expected RSA public key. */
    21712171#define VERR_CR_PKIX_NOT_RSA_PUBLIC_KEY             (-23524)
     2172/** Expected ECDSA private key. */
     2173#define VERR_CR_PKIX_NOT_ECDSA_PRIVATE_KEY          (-23525)
     2174/** Expected ECDSA public key. */
     2175#define VERR_CR_PKIX_NOT_ECDSA_PUBLIC_KEY           (-23526)
     2176/** OpenSSL failed to decode the key parameters. */
     2177#define VERR_CR_PKIX_OSSL_D2I_KEY_PARAMS_FAILED     (-23527)
    21722178/** @} */
    21732179
     
    22132219/** Failed to generate RSA key. */
    22142220#define VERR_CR_KEY_GEN_FAILED_RSA                  (-23815)
     2221/** Key algorithm parameters not expected. */
     2222#define VERR_CR_KEY_ALGO_PARAMS_UNEXPECTED          (-23816)
     2223/** Key algorithm parameters are required but missing. */
     2224#define VERR_CR_KEY_ALGO_PARAMS_MISSING             (-23817)
     2225/** Key algorithm parameters are not known/supported. */
     2226#define VERR_CR_KEY_ALGO_PARAMS_UNKNOWN             (-23818)
     2227/** Algorithm parameters does not match the key. */
     2228#define VERR_CR_KEY_ALGO_PARAMS_MISMATCH            (-23819)
     2229
    22152230/** @} */
    22162231
  • trunk/include/iprt/mangling.h

    r100422 r100442  
    35283528# define RTCrKeyQueryRsaModulus                         RT_MANGLER(RTCrKeyQueryRsaModulus)
    35293529# define RTCrKeyQueryRsaPrivateExponent                 RT_MANGLER(RTCrKeyQueryRsaPrivateExponent)
     3530# define RTCrKeyVerifyParameterCompatibility            RT_MANGLER(RTCrKeyVerifyParameterCompatibility)
    35303531# define RTCrRc4                                        RT_MANGLER(RTCrRc4)
    35313532# define RTCrRc4SetKey                                  RT_MANGLER(RTCrRc4SetKey)
     
    37093710# define RTCrPkixSignatureVerifyOctetString             RT_MANGLER(RTCrPkixSignatureVerifyOctetString)
    37103711# define RTCrPkixGetCiperOidFromSignatureAlgorithm      RT_MANGLER(RTCrPkixGetCiperOidFromSignatureAlgorithm)
     3712# define RTCrPkixGetCiperOidFromSignatureAlgorithmOid   RT_MANGLER(RTCrPkixGetCiperOidFromSignatureAlgorithmOid)
    37113713# define RTCrPkixPubKeySignDigest                       RT_MANGLER(RTCrPkixPubKeySignDigest)
    37123714# define RTCrPkixPubKeyVerifySignature                  RT_MANGLER(RTCrPkixPubKeyVerifySignature)
     
    38673869# define RTCrX509AlgorithmIdentifier_Delete             RT_MANGLER(RTCrX509AlgorithmIdentifier_Delete)
    38683870# define RTCrX509AlgorithmIdentifier_Enum               RT_MANGLER(RTCrX509AlgorithmIdentifier_Enum)
    3869 # define RTCrX509AlgorithmIdentifier_QueryDigestSize    RT_MANGLER(RTCrX509AlgorithmIdentifier_QueryDigestSize)
    3870 # define RTCrX509AlgorithmIdentifier_QueryDigestType    RT_MANGLER(RTCrX509AlgorithmIdentifier_QueryDigestType)
     3871# define RTCrX509AlgorithmIdentifier_GetDigestSize      RT_MANGLER(RTCrX509AlgorithmIdentifier_GetDigestSize)
     3872# define RTCrX509AlgorithmIdentifier_GetDigestType      RT_MANGLER(RTCrX509AlgorithmIdentifier_GetDigestType)
     3873# define RTCrX509AlgorithmIdentifier_GetEncryptionOid   RT_MANGLER(RTCrX509AlgorithmIdentifier_GetEncryptionOid)
     3874# define RTCrX509AlgorithmIdentifier_GetEncryptionOidFromOid RT_MANGLER(RTCrX509AlgorithmIdentifier_GetEncryptionOidFromOid)
    38713875# define RTCrX509AlgorithmIdentifiers_Compare           RT_MANGLER(RTCrX509AlgorithmIdentifiers_Compare)
    38723876# define RTCrX509AlgorithmIdentifiers_Delete            RT_MANGLER(RTCrX509AlgorithmIdentifiers_Delete)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette