Changeset 100421 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Jul 6, 2023 7:24:56 PM (20 months ago)
- svn:sync-xref-src-repo-rev:
- 158161
- Location:
- trunk/src/VBox/Runtime/common/crypto
- Files:
-
- 1 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/crypto/key-file.cpp
r98103 r100421 52 52 #include <iprt/string.h> 53 53 #include <iprt/crypto/rsa.h> 54 #include <iprt/crypto/pkcs8.h> 54 55 #include <iprt/crypto/pkix.h> 55 56 #include <iprt/crypto/x509.h> … … 470 471 471 472 case kKeyFormat_PrivateKeyInfo: 472 rc = RTErrInfoSet(pErrInfo, VERR_CR_KEY_FORMAT_NOT_SUPPORTED, 473 "Support for PKCS#8 PrivateKeyInfo is not yet implemented"); 473 RTAsn1CursorInitPrimary(&PrimaryCursor, pSection->pbData, (uint32_t)pSection->cbData, 474 pErrInfo, &g_RTAsn1DefaultAllocator, RTASN1CURSOR_FLAGS_DER, pszErrorTag); 475 RTCRPKCS8PRIVATEKEYINFO PrivateKeyInfo; 476 RT_ZERO(PrivateKeyInfo); 477 rc = RTCrPkcs8PrivateKeyInfo_DecodeAsn1(&PrimaryCursor.Cursor, 0, &PrivateKeyInfo, 478 pszErrorTag ? pszErrorTag : "PrivateKeyInfo"); 479 if (RT_SUCCESS(rc)) 480 { 481 /* 482 * Check if the algorithm is pkcs1-RsaEncryption 483 */ 484 if (strcmp(PrivateKeyInfo.PrivateKeyAlgorithm.Algorithm.szObjId,"1.2.840.113549.1.1.1") == 0) 485 { 486 uint32_t cbContent = PrivateKeyInfo.PrivateKey.Asn1Core.cb; 487 rc = rtCrKeyCreateRsaPrivate(phKey, PrivateKeyInfo.PrivateKey.Asn1Core.uData.pv, cbContent, pErrInfo, pszErrorTag); 488 } 489 else 490 { 491 rc = RTErrInfoSet(pErrInfo, VERR_CR_KEY_FORMAT_NOT_SUPPORTED, 492 "Support for PKCS#8 PrivateKeyInfo (with no RSA encryption) is not yet implemented"); 493 } 494 } 474 495 break; 475 496 -
trunk/src/VBox/Runtime/common/crypto/pkcs8-asn1-decoder.cpp
r99258 r100421 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Crypto - RSA, Decoder for ASN.1.3 * IPRT - Crypto - PKCS \#8, Decoder for ASN.1. 4 4 */ 5 5 … … 40 40 *********************************************************************************************************************************/ 41 41 #include "internal/iprt.h" 42 #include <iprt/crypto/ rsa.h>42 #include <iprt/crypto/pkcs8.h> 43 43 44 44 #include <iprt/errcore.h> 45 45 #include <iprt/string.h> 46 46 47 #include " rsa-internal.h"47 #include "pkcs8-internal.h" 48 48 49 49 /* -
trunk/src/VBox/Runtime/common/crypto/pkcs8-core.cpp
r99258 r100421 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Crypto - RSA, Core APIs.3 * IPRT - Crypto - PKCS \#8, Core APIs. 4 4 */ 5 5 … … 40 40 *********************************************************************************************************************************/ 41 41 #include "internal/iprt.h" 42 #include <iprt/crypto/ rsa.h>42 #include <iprt/crypto/pkcs8.h> 43 43 44 44 #include <iprt/errcore.h> … … 46 46 #include <iprt/string.h> 47 47 48 #include " rsa-internal.h"48 #include "pkcs8-internal.h" 49 49 50 50 /* -
trunk/src/VBox/Runtime/common/crypto/pkcs8-init.cpp
r99258 r100421 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Crypto - RSA, Initialization API.3 * IPRT - Crypto - PKCS \#8, Initialization API. 4 4 */ 5 5 … … 40 40 *********************************************************************************************************************************/ 41 41 #include "internal/iprt.h" 42 #include <iprt/crypto/ rsa.h>42 #include <iprt/crypto/pkcs8.h> 43 43 44 44 #include <iprt/errcore.h> 45 45 #include <iprt/string.h> 46 46 47 #include " rsa-internal.h"47 #include "pkcs8-internal.h" 48 48 49 49 /* -
trunk/src/VBox/Runtime/common/crypto/pkcs8-internal.h
r99258 r100421 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Crypto - RSA, Internal Header.3 * IPRT - Crypto - PKCS \#8, Internal Header. 4 4 */ 5 5 … … 35 35 */ 36 36 37 #ifndef IPRT_INCLUDED_SRC_common_crypto_ rsa_internal_h38 #define IPRT_INCLUDED_SRC_common_crypto_ rsa_internal_h37 #ifndef IPRT_INCLUDED_SRC_common_crypto_pkcs8_internal_h 38 #define IPRT_INCLUDED_SRC_common_crypto_pkcs8_internal_h 39 39 #ifndef RT_WITHOUT_PRAGMA_ONCE 40 40 # pragma once … … 44 44 #define RTCRRSA_MAX_MODULUS_BITS 16384 45 45 46 #define RTASN1TMPL_TEMPLATE_FILE "../common/crypto/ rsa-template.h"46 #define RTASN1TMPL_TEMPLATE_FILE "../common/crypto/pkcs8-template.h" 47 47 #include <iprt/asn1-generator-internal-header.h> 48 48 49 #endif /* !IPRT_INCLUDED_SRC_common_crypto_rsa_internal_h */ 50 49 #endif /* !IPRT_INCLUDED_SRC_common_crypto_pkcs8_internal_h */ -
trunk/src/VBox/Runtime/common/crypto/pkcs8-sanity.cpp
r99258 r100421 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Crypto - RSA, Sanity Checkers.3 * IPRT - Crypto - PKCS \#8, Sanity Checkers. 4 4 */ 5 5 … … 40 40 *********************************************************************************************************************************/ 41 41 #include "internal/iprt.h" 42 #include <iprt/crypto/ rsa.h>42 #include <iprt/crypto/pkcs8.h> 43 43 44 44 #include <iprt/errcore.h> 45 45 #include <iprt/string.h> 46 46 47 #include " rsa-internal.h"47 #include "pkcs8-internal.h" 48 48 49 49 /* -
trunk/src/VBox/Runtime/common/crypto/pkcs8-template.h
r99258 r100421 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Crypto - RSA, Code Generator Template.3 * IPRT - Crypto - PKCS \#8, Code Generator Template. 4 4 */ 5 5 … … 38 38 39 39 /* 40 * RSA public key.40 * PKCS\#8 Private key info 41 41 */ 42 #define RTASN1TMPL_TYPE RTCR RSAPUBLICKEY43 #define RTASN1TMPL_EXT_NAME RTCr RsaPublicKey44 #define RTASN1TMPL_INT_NAME r tCrRsaPublicKey42 #define RTASN1TMPL_TYPE RTCRPKCS8PRIVATEKEYINFO 43 #define RTASN1TMPL_EXT_NAME RTCrPkcs8PrivateKeyInfo 44 #define RTASN1TMPL_INT_NAME rTCrPkcs8PrivateKeyInfo 45 45 RTASN1TMPL_BEGIN_SEQCORE(); 46 RTASN1TMPL_MEMBER( Modulus, RTASN1INTEGER, RTAsn1Integer); 47 RTASN1TMPL_MEMBER( PublicExponent, RTASN1INTEGER, RTAsn1Integer); 46 RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer); 47 RTASN1TMPL_MEMBER( PrivateKeyAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier); 48 RTASN1TMPL_MEMBER( PrivateKey, RTASN1OCTETSTRING, RTAsn1OctetString); 49 RTASN1TMPL_MEMBER_OPT_ITAG( Attributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 0); 48 50 RTASN1TMPL_END_SEQCORE(); 49 51 #undef RTASN1TMPL_TYPE … … 51 53 #undef RTASN1TMPL_INT_NAME 52 54 55 #if 0 53 56 54 57 /* 55 * One RSA other prime info.58 * Encrypted private key info 56 59 */ 57 #define RTASN1TMPL_TYPE RTCR RSAOTHERPRIMEINFO58 #define RTASN1TMPL_EXT_NAME RTCr RsaOtherPrimeInfo59 #define RTASN1TMPL_INT_NAME rtCr RsaOtherPrimeInfo60 #define RTASN1TMPL_TYPE RTCRENCRYPTEDPRIVATEKEY 61 #define RTASN1TMPL_EXT_NAME RTCrEncryptedPrivateKey 62 #define RTASN1TMPL_INT_NAME rtCrEncryptedPrivateKey 60 63 RTASN1TMPL_BEGIN_SEQCORE(); 61 RTASN1TMPL_MEMBER( Prime, RTASN1INTEGER, RTAsn1Integer); 62 RTASN1TMPL_MEMBER( Exponent, RTASN1INTEGER, RTAsn1Integer); 63 RTASN1TMPL_MEMBER( Coefficient, RTASN1INTEGER, RTAsn1Integer); 64 RTASN1TMPL_MEMBER( EncryptionAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier); 65 RTASN1TMPL_MEMBER( EncryptedData, RTASN1OCTETSTRING, RTAsn1OctetString); 64 66 RTASN1TMPL_END_SEQCORE(); 65 67 #undef RTASN1TMPL_TYPE … … 67 69 #undef RTASN1TMPL_INT_NAME 68 70 69 70 /* 71 * Sequence of RSA other prime infos. 72 */ 73 #define RTASN1TMPL_TYPE RTCRRSAOTHERPRIMEINFOS 74 #define RTASN1TMPL_EXT_NAME RTCrRsaOtherPrimeInfos 75 #define RTASN1TMPL_INT_NAME rtCrRsaOtherPrimeInfos 76 RTASN1TMPL_SEQ_OF(RTCRRSAOTHERPRIMEINFO, RTCrRsaOtherPrimeInfo); 77 #undef RTASN1TMPL_TYPE 78 #undef RTASN1TMPL_EXT_NAME 79 #undef RTASN1TMPL_INT_NAME 80 81 82 /* 83 * RSA private key. 84 */ 85 #define RTASN1TMPL_TYPE RTCRRSAPRIVATEKEY 86 #define RTASN1TMPL_EXT_NAME RTCrRsaPrivateKey 87 #define RTASN1TMPL_INT_NAME rtCrRsaPrivateKey 88 RTASN1TMPL_BEGIN_SEQCORE(); 89 RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer); 90 RTASN1TMPL_MEMBER( Modulus, RTASN1INTEGER, RTAsn1Integer); 91 RTASN1TMPL_MEMBER( PublicExponent, RTASN1INTEGER, RTAsn1Integer); 92 RTASN1TMPL_MEMBER( PrivateExponent, RTASN1INTEGER, RTAsn1Integer); 93 RTASN1TMPL_MEMBER( Prime1, RTASN1INTEGER, RTAsn1Integer); 94 RTASN1TMPL_MEMBER( Prime2, RTASN1INTEGER, RTAsn1Integer); 95 RTASN1TMPL_MEMBER( Exponent1, RTASN1INTEGER, RTAsn1Integer); 96 RTASN1TMPL_MEMBER( Exponent2, RTASN1INTEGER, RTAsn1Integer); 97 RTASN1TMPL_MEMBER( Coefficient, RTASN1INTEGER, RTAsn1Integer); 98 RTASN1TMPL_MEMBER_OPT_ITAG_EX( OtherPrimeInfos, RTCRRSAOTHERPRIMEINFOS, RTCrRsaOtherPrimeInfos, ASN1_TAG_SEQUENCE, RTASN1TMPL_ITAG_F_UC, RT_NOTHING); 99 RTASN1TMPL_END_SEQCORE(); 100 #undef RTASN1TMPL_TYPE 101 #undef RTASN1TMPL_EXT_NAME 102 #undef RTASN1TMPL_INT_NAME 103 104 105 /* 106 * RSA Digest Info. 107 */ 108 #define RTASN1TMPL_TYPE RTCRRSADIGESTINFO 109 #define RTASN1TMPL_EXT_NAME RTCrRsaDigestInfo 110 #define RTASN1TMPL_INT_NAME rtCrRsaDigestInfo 111 RTASN1TMPL_BEGIN_SEQCORE(); 112 RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier); 113 RTASN1TMPL_MEMBER( Digest, RTASN1OCTETSTRING, RTAsn1OctetString); 114 RTASN1TMPL_END_SEQCORE(); 115 #undef RTASN1TMPL_TYPE 116 #undef RTASN1TMPL_EXT_NAME 117 #undef RTASN1TMPL_INT_NAME 118 71 #endif
Note:
See TracChangeset
for help on using the changeset viewer.