VirtualBox

Changeset 73665 in vbox for trunk/include


Ignore:
Timestamp:
Aug 14, 2018 5:49:23 PM (6 years ago)
Author:
vboxsync
Message:

IPRT,SUP,Main: Working on new crypto key handling and rsa signing. bugref:9152

Location:
trunk/include/iprt
Files:
1 added
4 edited

Legend:

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

    r69105 r73665  
    3232RT_C_DECLS_BEGIN
    3333
     34struct RTCRX509SUBJECTPUBLICKEYINFO;
     35
    3436/** @defgroup grp_rt_crpkix RTCrPkix - Public Key Infrastructure APIs
    3537 * @ingroup grp_rt_crypto
     
    4345 * @returns IPRT status code.
    4446 * @param   pAlgorithm      The signature algorithm (digest w/ cipher).
     47 * @param   hPublicKey      The public key.
    4548 * @param   pParameters     Parameter to the public key algorithm. Optional.
    46  * @param   pPublicKey      The public key.
    4749 * @param   pSignatureValue The signature value.
    4850 * @param   pvData          The signed data.
     
    5355 *          performed more than once using all available crypto implementations.
    5456 */
    55 RTDECL(int) RTCrPkixPubKeyVerifySignature(PCRTASN1OBJID pAlgorithm, PCRTASN1DYNTYPE pParameters, PCRTASN1BITSTRING pPublicKey,
     57RTDECL(int) RTCrPkixPubKeyVerifySignature(PCRTASN1OBJID pAlgorithm, RTCRKEY hPublicKey, PCRTASN1DYNTYPE pParameters,
    5658                                          PCRTASN1BITSTRING pSignatureValue, const void *pvData, size_t cbData,
    5759                                          PRTERRINFO pErrInfo);
     
    6466 * @returns IPRT status code.
    6567 * @param   pAlgorithm      The signature algorithm (digest w/ cipher).
     68 * @param   hPublicKey      The public key.
    6669 * @param   pParameters     Parameter to the public key algorithm. Optional.
    67  * @param   pPublicKey      The public key.
    6870 * @param   pvSignedDigest  The signed digest.
    6971 * @param   cbSignedDigest  The signed digest size.
     
    7577 *          performed more than once using all available crypto implementations.
    7678 */
    77 RTDECL(int) RTCrPkixPubKeyVerifySignedDigest(PCRTASN1OBJID pAlgorithm, PCRTASN1DYNTYPE pParameters,
    78                                              PCRTASN1BITSTRING pPublicKey, void const *pvSignedDigest, size_t cbSignedDigest,
     79RTDECL(int) RTCrPkixPubKeyVerifySignedDigest(PCRTASN1OBJID pAlgorithm, RTCRKEY hPublicKey, PCRTASN1DYNTYPE pParameters,
     80                                             void const *pvSignedDigest, size_t cbSignedDigest,
    7981                                             RTCRDIGEST hDigest, PRTERRINFO pErrInfo);
    8082
     83/**
     84 * Wrapper around RTCrPkixPubKeyVerifySignedDigest & RTCrKeyCreateFromAlgorithmAndBits.
     85 *
     86 * @note The public key info must include digest type for this to work.
     87 */
     88RTDECL(int) RTCrPkixPubKeyVerifySignedDigestByCertPubKeyInfo(struct RTCRX509SUBJECTPUBLICKEYINFO const *pCertPubKeyInfo,
     89                                                             void const *pvSignedDigest, size_t cbSignedDigest,
     90                                                             RTCRDIGEST hDigest, PRTERRINFO pErrInfo);
     91
     92
     93/**
     94 * Signs a digest (@a hDigest) using the specified private key (@a pPrivateKey) and algorithm.
     95 *
     96 * @returns IPRT status code.
     97 * @param   pAlgorithm      The signature algorithm (digest w/ cipher).
     98 * @param   hPrivateKey     Handle to the private key to use.
     99 * @param   pParameters     Parameter to the public key algorithm. Optional.
     100 * @param   hDigest         The digest of the data being signed.
     101 * @param   fFlags          Flags for future extensions, MBZ.
     102 * @param   pvSignature     The output signature buffer.  Pass NULL to query
     103 *                          the signature size.
     104 * @param   pcbSignature    On input the variable pointed to holds the size of
     105 *                          the buffer @a pvSignature points to.
     106 *                          On return the variable pointed to is set to the size
     107 *                          of the returned signature, or the required size in
     108 *                          case of VERR_BUFFER_OVERFLOW.
     109 * @param   pErrInfo        Where to return extended error info. Optional.
     110 *
     111 * @remarks Depending on the IPRT build configuration and the algorithm used, the
     112 *          signing may be performed more than once using all available crypto
     113 *          implementations.
     114 */
     115RTDECL(int) RTCrPkixPubKeySignDigest(PCRTASN1OBJID pAlgorithm, RTCRKEY hPrivateKey, PCRTASN1DYNTYPE pParameters,
     116                                     RTCRDIGEST hDigest, uint32_t fFlags,
     117                                     void *pvSignature, size_t *pcbSignature, PRTERRINFO pErrInfo);
    81118
    82119/**
     
    141178     *                          setting for the lifetime of the instance due to the
    142179     *                          algorithm requiring different keys.
    143      * @param   pKey            The key to use (whether private or public depends on
    144      *                          the operation).
     180     * @param   hKey            The key handle.  Caller has retained it for the
     181     *                          lifetime of the state being initialize.
    145182     * @param   pParams         Algorithm/key parameters, optional.  Will be NULL if
    146183     *                          none.
    147184     */
    148185    DECLCALLBACKMEMBER(int, pfnInit)(struct RTCRPKIXSIGNATUREDESC const *pDesc, void *pvState, void *pvOpaque, bool fSigning,
    149                                      PCRTASN1BITSTRING pKey, PCRTASN1DYNTYPE pParams);
     186                                     RTCRKEY hKey, PCRTASN1DYNTYPE pParams);
    150187
    151188    /**
     
    183220     * @param   pDesc           Pointer to this structure (for uProviderSpecific).
    184221     * @param   pvState         The opaque provider state.
     222     * @param   hKey            The key handle associated with the state at init.
    185223     * @param   hDigest         The handle to the digest.  Call RTCrDigestFinal to
    186224     *                          complete and retreive the final hash value.
     
    188226     * @param   cbSignature     The size of the signature (in bytes).
    189227     */
    190     DECLCALLBACKMEMBER(int, pfnVerify)(struct RTCRPKIXSIGNATUREDESC const *pDesc, void *pvState,
     228    DECLCALLBACKMEMBER(int, pfnVerify)(struct RTCRPKIXSIGNATUREDESC const *pDesc, void *pvState, RTCRKEY hKey,
    191229                                       RTCRDIGEST hDigest, void const *pvSignature, size_t cbSignature);
    192230
     
    202240     * @param   pDesc           Pointer to this structure (for uProviderSpecific).
    203241     * @param   pvState         The opaque provider state.
     242     * @param   hKey            The key handle associated with the state at init.
    204243     * @param   hDigest         The handle to the digest.  Call RTCrDigestFinal to
    205244     *                          complete and retreive the final hash value.
     
    211250     *                          case of VERR_BUFFER_OVERFLOW.
    212251     */
    213     DECLCALLBACKMEMBER(int, pfnSign)(struct RTCRPKIXSIGNATUREDESC const *pDesc, void *pvState,
     252    DECLCALLBACKMEMBER(int, pfnSign)(struct RTCRPKIXSIGNATUREDESC const *pDesc, void *pvState, RTCRKEY hKey,
    214253                                     RTCRDIGEST hDigest, void *pvSignature, size_t *pcbSignature);
    215254
     
    220259
    221260PCRTCRPKIXSIGNATUREDESC RTCrPkixSignatureFindByObjIdString(const char *pszObjId, void *ppvOpaque);
    222 PCRTCRPKIXSIGNATUREDESC RTCrPkixSignatureFindByObjId(PCRTASN1OBJID pObjId, void *ppvOpaque);
     261PCRTCRPKIXSIGNATUREDESC RTCrPkixSignatureFindByObjId(PCRTASN1OBJID pObjId, void **ppvOpaque);
    223262RTDECL(int) RTCrPkixSignatureCreateByObjIdString(PRTCRPKIXSIGNATURE phSignature, const char *pszObjId, bool fSigning,
    224                                                  PCRTASN1BITSTRING pKey,PCRTASN1DYNTYPE pParams);
    225 RTDECL(int) RTCrPkixSignatureCreateByObjId(PRTCRPKIXSIGNATURE phSignature, PCRTASN1OBJID pObjId, bool fSigning,
    226                                            PCRTASN1BITSTRING pKey, PCRTASN1DYNTYPE pParams);
     263                                                 RTCRKEY hKey, PCRTASN1DYNTYPE pParams);
     264RTDECL(int) RTCrPkixSignatureCreateByObjId(PRTCRPKIXSIGNATURE phSignature, PCRTASN1OBJID pObjId, RTCRKEY hKey,
     265                                           PCRTASN1DYNTYPE pParams, bool fSigning);
    227266
    228267
    229268RTDECL(int) RTCrPkixSignatureCreate(PRTCRPKIXSIGNATURE phSignature, PCRTCRPKIXSIGNATUREDESC pDesc, void *pvOpaque,
    230                                     bool fSigning, PCRTASN1BITSTRING pKey, PCRTASN1DYNTYPE pParams);
     269                                    bool fSigning, RTCRKEY hKey, PCRTASN1DYNTYPE pParams);
    231270RTDECL(uint32_t) RTCrPkixSignatureRetain(RTCRPKIXSIGNATURE hSignature);
    232271RTDECL(uint32_t) RTCrPkixSignatureRelease(RTCRPKIXSIGNATURE hSignature);
  • trunk/include/iprt/err.h

    r73494 r73665  
    27292729/** The EVP_PKEY_type API in OpenSSL failed.  */
    27302730#define VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR       (-23517)
     2731/** OpenSSL failed to decode the public key. */
     2732#define VERR_CR_PKIX_OSSL_D2I_PRIVATE_KEY_FAILED    (-23518)
     2733/** The EVP_PKEY_CTX_set_rsa_padding API in OpenSSL failed.  */
     2734#define VERR_CR_PKIX_OSSL_EVP_PKEY_RSA_PAD_ERROR    (-23519)
     2735/** Final OpenSSL PKIX signing failed. */
     2736#define VERR_CR_PKIX_OSSL_SIGN_FINAL_FAILED         (-23520)
     2737/** OpenSSL and IPRT disagree on the signature size. */
     2738#define VERR_CR_PKIX_OSSL_VS_IPRT_SIGNATURE_SIZE    (-23521)
     2739/** OpenSSL and IPRT disagree on the signature. */
     2740#define VERR_CR_PKIX_OSSL_VS_IPRT_SIGNATURE         (-23522)
     2741/** Expected RSA private key. */
     2742#define VERR_CR_PKIX_NOT_RSA_PRIVATE_KEY            (-23523)
     2743/** Expected RSA public key. */
     2744#define VERR_CR_PKIX_NOT_RSA_PUBLIC_KEY             (-23524)
    27312745/** @} */
    27322746
     
    27352749/** Generic store error. */
    27362750#define VERR_CR_STORE_GENERIC_ERROR                 (-23700)
     2751/** @} */
     2752
     2753/** @name RTCrKey status codes.
     2754 * @{ */
     2755/** Could not recognize the key type. */
     2756#define VERR_CR_KEY_UNKNOWN_TYPE                    (-23800)
     2757/** Unsupported key format. */
     2758#define VERR_CR_KEY_FORMAT_NOT_SUPPORTED            (-23801)
    27372759/** @} */
    27382760
  • trunk/include/iprt/mangling.h

    r73662 r73665  
    31113111# define RTCrDigestTypeToName                           RT_MANGLER(RTCrDigestTypeToName)
    31123112# define RTCrDigestTypeToHashSize                       RT_MANGLER(RTCrDigestTypeToHashSize)
     3113# define RTCrKeyCreateFromBuffer                        RT_MANGLER(RTCrKeyCreateFromBuffer)
     3114# define RTCrKeyCreateFromFile                          RT_MANGLER(RTCrKeyCreateFromFile)
     3115# define RTCrKeyCreateFromPemSection                    RT_MANGLER(RTCrKeyCreateFromPemSection)
     3116# define RTCrKeyCreateFromPublicAlgorithmAndBits        RT_MANGLER(RTCrKeyCreateFromPublicAlgorithmAndBits)
     3117# define RTCrKeyCreateFromSubjectPublicKeyInfo          RT_MANGLER(RTCrKeyCreateFromSubjectPublicKeyInfo)
     3118# define RTCrKeyGetBitCount                             RT_MANGLER(RTCrKeyGetBitCount)
     3119# define RTCrKeyGetType                                 RT_MANGLER(RTCrKeyGetType)
     3120# define RTCrKeyHasPrivatePart                          RT_MANGLER(RTCrKeyHasPrivatePart)
     3121# define RTCrKeyHasPublicPart                           RT_MANGLER(RTCrKeyHasPublicPart)
     3122# define RTCrKeyRelease                                 RT_MANGLER(RTCrKeyRelease)
     3123# define RTCrKeyRetain                                  RT_MANGLER(RTCrKeyRetain)
    31133124# define RTCrRsaDigestInfo_DecodeAsn1                   RT_MANGLER(RTCrRsaDigestInfo_DecodeAsn1)
    31143125# define RTCrRsaOtherPrimeInfo_DecodeAsn1               RT_MANGLER(RTCrRsaOtherPrimeInfo_DecodeAsn1)
  • trunk/include/iprt/types.h

    r73475 r73665  
    20872087#define NIL_RTCRDIGEST                              (0)
    20882088
     2089/** Cryptographic key handle. */
     2090typedef R3R0PTRTYPE(struct RTCRKEYINT RT_FAR *)     RTCRKEY;
     2091/** Pointer to a cryptographic key handle. */
     2092typedef RTCRKEY                             RT_FAR *PRTCRKEY;
     2093/** Cryptographic key handle nil value. */
     2094#define NIL_RTCRKEY                                 (0)
     2095
    20892096/** Public key encryption schema handle. */
    20902097typedef R3R0PTRTYPE(struct RTCRPKIXENCRYPTIONINT RT_FAR *) RTCRPKIXENCRYPTION;
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