Changeset 100421 in vbox
- Timestamp:
- Jul 6, 2023 7:24:56 PM (19 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r100314 r100421 455 455 common/crypto/pkcs7-sign.cpp \ 456 456 common/crypto/pkcs7-verify.cpp \ 457 common/crypto/pkcs8-asn1-decoder.cpp \ 458 common/crypto/pkcs8-core.cpp \ 459 common/crypto/pkcs8-init.cpp \ 460 common/crypto/pkcs8-sanity.cpp \ 457 461 common/crypto/pkix-sign.cpp \ 458 462 common/crypto/pkix-signature-builtin.cpp \ … … 2298 2302 common/crypto/pkcs7-sanity.cpp \ 2299 2303 common/crypto/pkcs7-verify.cpp \ 2304 common/crypto/pkcs8-asn1-decoder.cpp \ 2305 common/crypto/pkcs8-core.cpp \ 2306 common/crypto/pkcs8-init.cpp \ 2307 common/crypto/pkcs8-sanity.cpp \ 2300 2308 common/crypto/pkix-signature-builtin.cpp \ 2301 2309 common/crypto/pkix-signature-core.cpp \ … … 3709 3717 common/crypto/pkcs7-sanity.cpp \ 3710 3718 common/crypto/pkcs7-verify.cpp \ 3719 common/crypto/pkcs8-asn1-decoder.cpp \ 3720 common/crypto/pkcs8-core.cpp \ 3721 common/crypto/pkcs8-init.cpp \ 3722 common/crypto/pkcs8-sanity.cpp \ 3711 3723 common/crypto/pkix-signature-builtin.cpp \ 3712 3724 common/crypto/pkix-signature-core.cpp \ … … 3862 3874 common/crypto/pkcs7-sanity.cpp \ 3863 3875 common/crypto/pkcs7-verify.cpp \ 3876 common/crypto/pkcs8-asn1-decoder.cpp \ 3877 common/crypto/pkcs8-core.cpp \ 3878 common/crypto/pkcs8-init.cpp \ 3879 common/crypto/pkcs8-sanity.cpp \ 3864 3880 common/crypto/pkix-signature-builtin.cpp \ 3865 3881 common/crypto/pkix-signature-core.cpp \ … … 4914 4930 x509-template.o x509-template.obj: x509-core.o x509-asn1-decoder.o x509-sanity.o x509-init.o 4915 4931 pkcs7-template.o pkcs7-template.obj: pkcs7-core.o pkcs7-asn1-decoder.o pkcs7-sanity.o pkcs7-init.o 4932 pkcs8-template.o pkcs8-template.obj: pkcs8-core.o pkcs8-asn1-decoder.o pkcs8-sanity.o pkcs8-init.o -
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 -
trunk/src/VBox/Runtime/testcase/tstRTCrPkix-1.cpp
r98103 r100421 255 255 "-----END PUBLIC KEY-----\n", 256 256 "password" 257 }, 258 259 /* 260 * PKCS8 Test Keys 261 */ 262 { 263 1024, 264 "-----BEGIN PRIVATE KEY-----\n" 265 "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAK4uHX+XRbLQ7dGm\n" 266 "sE1IqNDi4Obf7WS2TwfklmterJvCMrN3DxDAFq9et5j8kFRtI0Lgbc6sVAxlSkaw\n" 267 "+0LltbkC8JX0cjPSIlozzcZn+9dQ+m5rVLDl3AaV3kBLrYpnNggdTRiHuVbNPqZq\n" 268 "0CNDMxCqHpqRjtIOuoKukcOZasD5AgMBAAECgYA4IlKNaTIkM+NBGshcz9rgHw4+\n" 269 "OdKnD34e3BOCHOvh8s8mOWuYiV+GOy9OVa8qFlYz2mJpJe6cZBRw/d6sK53Jrzc1\n" 270 "ULULW9YNqgkhdhTm0z8QolYjBU+qp9pAXhh29tCdMxgCWAsiVR9jsnFtPQX4QEmM\n" 271 "9t+65ghTFQWtQXMqpQJBANly600i4GYoxvzvp67RvUkmnG47LvwuVRMwUAmAX6QP\n" 272 "Ww5q6aJd9HnHttLsNHxgX49aVxgpFu2uJI2SwSV3qwMCQQDND2kty83UXW5RahIt\n" 273 "BXAY8W60Itw6+bPLg3P4IixDCoHphnLqkz5ZT2NxxPsAPGeaFZDVyNs3Hgasnd8V\n" 274 "V8VTAkEAi4KWgrvQmtqoqFkeDSRVvBwAmxxvja4wOQpzH1V0hy6u7fYcBWcgVg2T\n" 275 "N4oCNpYiWTfNzxt1sXJb01UHhIFdfwJAO8ZiQpdGSMFzhwgEhFsxchPu0VPYHtjr\n" 276 "MEgBZjOP83r8o7YtiXOimSYrNt7UzBzPlnry3V7PiCGYkHj0rqQHQQJBANi5N5X4\n" 277 "g7dNDsE5i1B0JsQ4ru8qE60ZtoOOCwNjwiI/IIsMVW2KqhTBynEYLnWolkRRogEF\n" 278 "ACoRRxUBhj9EefI=\n" 279 "-----END PRIVATE KEY-----\n", 280 "-----BEGIN PUBLIC KEY-----\n" 281 "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuLh1/l0Wy0O3RprBNSKjQ4uDm\n" 282 "3+1ktk8H5JZrXqybwjKzdw8QwBavXreY/JBUbSNC4G3OrFQMZUpGsPtC5bW5AvCV\n" 283 "9HIz0iJaM83GZ/vXUPpua1Sw5dwGld5AS62KZzYIHU0Yh7lWzT6matAjQzMQqh6a\n" 284 "kY7SDrqCrpHDmWrA+QIDAQAB\n" 285 "-----END PUBLIC KEY-----\n", 286 NULL 257 287 } 258 288 };
Note:
See TracChangeset
for help on using the changeset viewer.