它是一種SubjectPublicKeyInfo
(SPKI)。您需要在HexDecoding
之後撥打Load
。
首先,它保存到一個文件中ASN.1/DER
,看看它是什麼:
string dek("30819D300D06092A864886F70D010101050003818B0030818702818100B126088"
"1BDFE84463D88C6AB8DB914A2E593893C10508B8A5ABDF692E9A5419A3EDBAE86"
"A052849983B75E3B425C18178B260003D857DF0B6505C6CF9C84F5859FCE3B63F"
"1FB2D4818501F6C5FA4AD1430EEB081A74ABD74CD1F4AA1FCCA3B88DD0548AED3"
"4443CEB52444EAE9099AA4FE66B2E6224D02381C248025C7044079020111");
HexDecoder decoder(new FileSink("key.der", true));
decoder.Put((const byte*)dek.data(), dek.size());
decoder.MessageEnd();
然後,看到它與Gutmann的dumpasn1
什麼:
$ dumpasn1 key.der
0 157: SEQUENCE {
3 13: SEQUENCE {
5 9: OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1)
16 0: NULL
: }
18 139: BIT STRING, encapsulates {
22 135: SEQUENCE {
25 129: INTEGER
: 00 B1 26 08 81 BD FE 84 46 3D 88 C6 AB 8D B9 14
: A2 E5 93 89 3C 10 50 8B 8A 5A BD F6 92 E9 A5 41
: 9A 3E DB AE 86 A0 52 84 99 83 B7 5E 3B 42 5C 18
: 17 8B 26 00 03 D8 57 DF 0B 65 05 C6 CF 9C 84 F5
: 85 9F CE 3B 63 F1 FB 2D 48 18 50 1F 6C 5F A4 AD
: 14 30 EE B0 81 A7 4A BD 74 CD 1F 4A A1 FC CA 3B
: 88 DD 05 48 AE D3 44 43 CE B5 24 44 EA E9 09 9A
: A4 FE 66 B2 E6 22 4D 02 38 1C 24 80 25 C7 04 40
: 79
157 1: INTEGER 17
: }
: }
: }
rsaEncryption (1 2 840 113549 1 1 1)
告訴你它的RSA密鑰和SPKI。
因此,這裏是我怎麼可能做到這一點:
AutoSeededRandomPool prng;
string dek("30819D300D06092A864886F70D010101050003818B0030818702818100B126088"
"1BDFE84463D88C6AB8DB914A2E593893C10508B8A5ABDF692E9A5419A3EDBAE86"
"A052849983B75E3B425C18178B260003D857DF0B6505C6CF9C84F5859FCE3B63F"
"1FB2D4818501F6C5FA4AD1430EEB081A74ABD74CD1F4AA1FCCA3B88DD0548AED3"
"4443CEB52444EAE9099AA4FE66B2E6224D02381C248025C7044079020111");
try {
ByteQueue queue;
HexDecoder decoder(new Redirector(queue));
decoder.Put((const byte*)dek.data(), dek.size());
decoder.MessageEnd();
RSASSA_PKCS1v15_SHA_Verifier verifier;
verifier.AccessKey().Load(queue);
if (!verifier.AccessKey().Validate(prng, 3))
throw Exception(Exception::OTHER_ERROR, "Failed to validate public key");
cout << "Verified key" << endl;
}
catch(CryptoPP::Exception& ex)
{
cerr << ex.what() << endl;
}
程序的結果(如預期):
$ ./cryptopp-test.exe
Verified key
根據你提供以下引擎收錄(一些相當差的格式添加我):
text:1002712F
mov
[ebp+a1], offset [email protected][email protected]?
[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@
[email protected]@[email protected]@@[email protected]@@[email protected]@6B?
[email protected][email protected]?
[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@
[email protected]
[email protected]@[email protected]@[email protected]@@[email protected]@@ ; const
CryptoPP::TF_VerifierImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<
CryptoPP::PKCS1v15,CryptoPP::SHA1,CryptoPP::RSA,int>,
CryptoPP::RSA,CryptoPP::PKCS1v15_SignatureMessageEncodingMethod,
CryptoPP::SHA1>>::`vftable'{for `CryptoPP::TF_VerifierImpl<
CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<
CryptoPP::PKCS1v15,CryptoPP::SHA1,CryptoPP::RSA,int>,
CryptoPP::RSA,CryptoPP::PKCS1v15_SignatureMessageEncodingMethod,CryptoPP::SHA1>>'
我猜RSASSA_PKCS1v15_SHA_Verifier
會好的。但是直到你試圖使用編碼簽名時纔會知道。
如果RSASSA_PKCS1v15_SHA_Verifier
不工作,那麼嘗試添加使用SHA256
一個typedef
:
typedef RSASS<PKCS1v15, SHA256>::Signer RSASSA_PKCS1v15_SHA256_Signer;
typedef RSASS<PKCS1v15, SHA256>::Verifier RSASSA_PKCS1v15_SHA256_Verifier;
下面是從庫中的原始typedefs
在rsa.h
:
00161 typedef RSASS<PKCS1v15, SHA>::Signer RSASSA_PKCS1v15_SHA_Signer;
00162 typedef RSASS<PKCS1v15, SHA>::Verifier RSASSA_PKCS1v15_SHA_Verifier;
的加密+維基在Keys and Formats上有一個頁面。它看起來很漫長,直到你有一個具體的例子看:)它甚至向你展示瞭如何使用其他庫,如OpenSSL和GnuTLS創建密鑰。
它看起來不像我PKCS#1 RSA公鑰的BER編碼。也許一個X.509 SubjectPublicKeyInfo? –
下面是使用密鑰時的一些相關代碼,讓我相信它是PKCS#1(基本上它是對象的VTable類型,它似乎是從我傾銷的密鑰構建的):http:// pastie。組織/粘貼/ 9827716 /文 – RaptorFactor
這可能當然是紅鯡魚雖然... – RaptorFactor