зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1136278
, Part 2: Refactor test SubjectPublicKeyInfo generation, r=keeler
--HG-- extra : rebase_source : 7bb0327749fd013ba5de17483d21a9e9f21eb07a extra : source : 9f3617a5b85a8a2ae9a82c0f0584b413a9b635b4
This commit is contained in:
Родитель
3ab08d7fdb
Коммит
36b7acc82a
|
@ -15,8 +15,8 @@
|
||||||
namespace mozilla { namespace pkix { namespace test {
|
namespace mozilla { namespace pkix { namespace test {
|
||||||
|
|
||||||
// Ownership of privateKey is transfered.
|
// Ownership of privateKey is transfered.
|
||||||
TestKeyPair* CreateTestKeyPair(const ByteString& spki,
|
TestKeyPair* CreateTestKeyPair(const TestPublicKeyAlgorithm publicKeyAlg,
|
||||||
const ByteString& spk,
|
const SECKEYPublicKey& publicKey,
|
||||||
SECKEYPrivateKey* privateKey);
|
SECKEYPrivateKey* privateKey);
|
||||||
|
|
||||||
} } } // namespace mozilla::pkix::test
|
} } } // namespace mozilla::pkix::test
|
||||||
|
@ -33,14 +33,11 @@ CreateTestKeyPairFromCert(CERTCertificate& cert)
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ByteString subjectPublicKeyInfo(cert.derPublicKey.data,
|
ScopedSECKEYPublicKey publicKey(CERT_ExtractPublicKey(&cert));
|
||||||
cert.derPublicKey.len);
|
if (!publicKey) {
|
||||||
SECItem subjectPublicKeyItem = cert.subjectPublicKeyInfo.subjectPublicKey;
|
return nullptr;
|
||||||
DER_ConvertBitString(&subjectPublicKeyItem); // bits to bytes
|
}
|
||||||
ByteString subjectPublicKey(subjectPublicKeyItem.data,
|
return CreateTestKeyPair(RSA_PKCS1(), *publicKey, privateKey.forget());
|
||||||
subjectPublicKeyItem.len);
|
|
||||||
return CreateTestKeyPair(subjectPublicKeyInfo, subjectPublicKey,
|
|
||||||
privateKey.forget());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECItemArray *
|
SECItemArray *
|
||||||
|
|
|
@ -60,6 +60,80 @@ SimpleAlgID(const uint8_t (&rawValue)[SIZE],
|
||||||
return TLV(der::SEQUENCE, sequenceValue);
|
return TLV(der::SEQUENCE, sequenceValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <size_t SIZE>
|
||||||
|
ByteString
|
||||||
|
DERInteger(const uint8_t (&rawValue)[SIZE])
|
||||||
|
{
|
||||||
|
ByteString value(rawValue, SIZE);
|
||||||
|
if (value[0] & 0x80u) {
|
||||||
|
// Prefix with a leading zero to disambiguate this from a negative value.
|
||||||
|
value.insert(value.begin(), 0x00);
|
||||||
|
}
|
||||||
|
return TLV(der::INTEGER, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generated with "openssl dsaparam -C -noout 2048" and reformatted.
|
||||||
|
// openssl 1.0 or later must be used so that a 256-bit Q value is
|
||||||
|
// generated.
|
||||||
|
static const uint8_t DSS_P_RAW[] =
|
||||||
|
{
|
||||||
|
0xB3,0xCD,0x29,0x44,0xF0,0x25,0xA7,0x73,0xFC,0x86,0x70,0xA2,
|
||||||
|
0x69,0x5A,0x97,0x3F,0xBD,0x1C,0x6F,0xAA,0x4A,0x40,0x42,0x8E,
|
||||||
|
0xCF,0xAE,0x62,0x12,0xED,0xB4,0xFD,0x05,0xC2,0xAE,0xB1,0x8C,
|
||||||
|
0xFC,0xBE,0x38,0x90,0xBB,0x7C,0xFF,0x16,0xF4,0xED,0xCE,0x72,
|
||||||
|
0x12,0x93,0x83,0xF0,0xA4,0xA1,0x71,0xDC,0x4B,0xF0,0x4E,0x3A,
|
||||||
|
0x2B,0xFA,0x17,0xB7,0xB3,0x2A,0xCC,0x2C,0xD3,0xC8,0x21,0x49,
|
||||||
|
0x7A,0x83,0x71,0x8B,0x3D,0x62,0x96,0xDC,0xAD,0xA8,0x03,0xBE,
|
||||||
|
0x1D,0x33,0x11,0xF3,0xEB,0xD8,0x1B,0x8D,0xDB,0x62,0x79,0x83,
|
||||||
|
0xF8,0x67,0x4E,0x62,0x21,0x2C,0x81,0x59,0xE8,0x73,0xD7,0xAF,
|
||||||
|
0xB9,0x63,0x60,0xEA,0xAE,0xEC,0x68,0x6A,0xB4,0xB0,0x65,0xBA,
|
||||||
|
0xA3,0x4C,0x09,0x99,0x29,0x6A,0x2E,0x2B,0xFC,0x6D,0x51,0xCA,
|
||||||
|
0x30,0xA2,0x2F,0x7A,0x65,0x76,0xA7,0x55,0x13,0x11,0xA0,0x02,
|
||||||
|
0xA2,0x59,0x4B,0xCE,0xA7,0x05,0xF6,0x07,0x35,0x9B,0x41,0xD7,
|
||||||
|
0x11,0x5A,0x18,0x57,0xA7,0x78,0x88,0xC3,0xA8,0xE3,0x39,0xF5,
|
||||||
|
0x47,0x3D,0x2E,0x18,0x54,0xB0,0xF0,0xBF,0x65,0x3F,0x77,0xC7,
|
||||||
|
0x11,0xB8,0x0D,0x52,0xAD,0xC8,0xE8,0x6D,0xF6,0x7E,0x88,0x65,
|
||||||
|
0x84,0x2B,0xF7,0xEF,0x8E,0xB5,0x7C,0xBD,0x2E,0x0D,0xF3,0xC6,
|
||||||
|
0xDD,0x0B,0xB4,0xF2,0x23,0x1F,0xDA,0x55,0x05,0xF5,0xDC,0x53,
|
||||||
|
0xA6,0x83,0xDA,0x5C,0xEF,0x29,0x02,0x78,0x68,0xD0,0xA4,0x39,
|
||||||
|
0x09,0x7F,0xFA,0x49,0x18,0xD0,0xB5,0x19,0x35,0x31,0x8E,0xDE,
|
||||||
|
0x43,0x35,0xA3,0xB9,0x6D,0xC1,0x70,0xC6,0x0D,0x18,0x24,0xEB,
|
||||||
|
0x1E,0x4D,0x52,0xB7,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t DSS_Q_RAW[] =
|
||||||
|
{
|
||||||
|
0x8D,0x6B,0x86,0x89,0x9C,0x8D,0x30,0x91,0xCC,0x6E,0x34,0xF1,
|
||||||
|
0xE8,0x9C,0x8A,0x5C,0xD6,0xAB,0x01,0x1E,0xC4,0xDB,0xFD,0x07,
|
||||||
|
0xEB,0x5F,0x4E,0xE8,0xFA,0xFC,0x98,0x2D,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t DSS_G_RAW[] =
|
||||||
|
{
|
||||||
|
0x0E,0x2C,0x34,0xB2,0xE1,0x66,0x49,0xB6,0x9A,0x7D,0x67,0x3E,
|
||||||
|
0xEE,0x98,0x35,0x18,0x28,0x35,0xFC,0x05,0x36,0x3B,0x94,0xE6,
|
||||||
|
0x1E,0x1C,0x5B,0x05,0x3E,0x86,0x1B,0xE3,0xED,0xD2,0xE1,0xF3,
|
||||||
|
0xF7,0xF7,0x60,0x6D,0x7D,0xA1,0xAF,0x9A,0xD1,0xDF,0xA2,0x9C,
|
||||||
|
0xFC,0xA2,0xEB,0x90,0x8B,0x1C,0x82,0x92,0x45,0x7B,0x30,0x2A,
|
||||||
|
0xFD,0x7A,0xE6,0x68,0x8F,0xEC,0x89,0x3A,0x9A,0xAD,0xFE,0x25,
|
||||||
|
0x5E,0x51,0xC5,0x29,0x45,0x7F,0xAC,0xDE,0xFC,0xB4,0x1B,0x3A,
|
||||||
|
0xDA,0xC7,0x21,0x68,0x87,0x27,0x8D,0x7B,0xB2,0xBB,0x41,0x60,
|
||||||
|
0x46,0x42,0x5B,0x6B,0xE8,0x80,0xD2,0xE4,0xA3,0x30,0x8F,0xD5,
|
||||||
|
0x71,0x07,0x8A,0x7B,0x32,0x56,0x84,0x41,0x1C,0xDF,0x69,0xE9,
|
||||||
|
0xFD,0xBA,0x48,0xE0,0x43,0xA0,0x38,0x92,0x12,0xF3,0x52,0xA5,
|
||||||
|
0x40,0x87,0xCB,0x34,0xBB,0x3E,0x25,0x29,0x3C,0xC6,0xA5,0x17,
|
||||||
|
0xFD,0x58,0x47,0x89,0xDB,0x9B,0xB9,0xCF,0xE9,0xA8,0xF2,0xEC,
|
||||||
|
0x55,0x76,0xF5,0xF1,0x9C,0x6E,0x0A,0x3F,0x16,0x5F,0x49,0x31,
|
||||||
|
0x31,0x1C,0x43,0xA2,0x83,0xDA,0xDD,0x7F,0x1C,0xEA,0x05,0x36,
|
||||||
|
0x7B,0xED,0x09,0xFB,0x6F,0x8A,0x2B,0x55,0xB9,0xBC,0x4A,0x8C,
|
||||||
|
0x28,0xC1,0x4D,0x13,0x6E,0x47,0xF4,0xAD,0x79,0x00,0xE9,0x5A,
|
||||||
|
0xB6,0xC7,0x73,0x28,0xA9,0x89,0xAD,0xE8,0x6E,0xC6,0x54,0xA5,
|
||||||
|
0x56,0x2D,0xAA,0x81,0x83,0x9E,0xC1,0x13,0x79,0xA4,0x12,0xE0,
|
||||||
|
0x76,0x1F,0x25,0x43,0xB6,0xDE,0x56,0xF7,0x52,0xCC,0x07,0xB8,
|
||||||
|
0x37,0xE2,0x8C,0xC5,0x56,0x8C,0xDD,0x63,0xF5,0xB6,0xA3,0x46,
|
||||||
|
0x62,0xF6,0x35,0x76,
|
||||||
|
};
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
TestSignatureAlgorithm::TestSignatureAlgorithm(
|
TestSignatureAlgorithm::TestSignatureAlgorithm(
|
||||||
|
@ -74,6 +148,25 @@ TestSignatureAlgorithm::TestSignatureAlgorithm(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ByteString DSS_P() { return ByteString(DSS_P_RAW, sizeof(DSS_P_RAW)); }
|
||||||
|
ByteString DSS_Q() { return ByteString(DSS_Q_RAW, sizeof(DSS_Q_RAW)); }
|
||||||
|
ByteString DSS_G() { return ByteString(DSS_G_RAW, sizeof(DSS_G_RAW)); }
|
||||||
|
|
||||||
|
TestPublicKeyAlgorithm
|
||||||
|
DSS()
|
||||||
|
{
|
||||||
|
static const uint8_t oidValue[] = { PREFIX_1_2_840_10040, 4, 1 };
|
||||||
|
|
||||||
|
// RFC 3279 Section-2.3.2
|
||||||
|
return TestPublicKeyAlgorithm(
|
||||||
|
TLV(der::SEQUENCE,
|
||||||
|
OID(oidValue) +
|
||||||
|
TLV(der::SEQUENCE,
|
||||||
|
DERInteger(DSS_P_RAW) +
|
||||||
|
DERInteger(DSS_Q_RAW) +
|
||||||
|
DERInteger(DSS_G_RAW))));
|
||||||
|
}
|
||||||
|
|
||||||
// RFC 3279 Section 2.3.1
|
// RFC 3279 Section 2.3.1
|
||||||
TestPublicKeyAlgorithm
|
TestPublicKeyAlgorithm
|
||||||
RSA_PKCS1()
|
RSA_PKCS1()
|
||||||
|
|
|
@ -79,10 +79,10 @@ class NSSTestKeyPair final : public TestKeyPair
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// NSSTestKeyPair takes ownership of privateKey.
|
// NSSTestKeyPair takes ownership of privateKey.
|
||||||
NSSTestKeyPair(const ByteString& spki,
|
NSSTestKeyPair(const TestPublicKeyAlgorithm& publicKeyAlg,
|
||||||
const ByteString& spk,
|
const ByteString& spk,
|
||||||
SECKEYPrivateKey* privateKey)
|
SECKEYPrivateKey* privateKey)
|
||||||
: TestKeyPair(spki, spk)
|
: TestKeyPair(publicKeyAlg, spk)
|
||||||
, privateKey(privateKey)
|
, privateKey(privateKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public:
|
||||||
if (!privateKeyCopy) {
|
if (!privateKeyCopy) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return new (std::nothrow) NSSTestKeyPair(subjectPublicKeyInfo,
|
return new (std::nothrow) NSSTestKeyPair(publicKeyAlg,
|
||||||
subjectPublicKey,
|
subjectPublicKey,
|
||||||
privateKeyCopy.release());
|
privateKeyCopy.release());
|
||||||
}
|
}
|
||||||
|
@ -154,11 +154,20 @@ private:
|
||||||
// (OCSPCommon.cpp).
|
// (OCSPCommon.cpp).
|
||||||
//
|
//
|
||||||
// Ownership of privateKey is transfered.
|
// Ownership of privateKey is transfered.
|
||||||
TestKeyPair* CreateTestKeyPair(const ByteString& spki,
|
TestKeyPair* CreateTestKeyPair(const TestPublicKeyAlgorithm publicKeyAlg,
|
||||||
const ByteString& spk,
|
const SECKEYPublicKey& publicKey,
|
||||||
SECKEYPrivateKey* privateKey)
|
SECKEYPrivateKey* privateKey)
|
||||||
{
|
{
|
||||||
return new (std::nothrow) NSSTestKeyPair(spki, spk, privateKey);
|
ScopedPtr<CERTSubjectPublicKeyInfo, SECKEY_DestroySubjectPublicKeyInfo>
|
||||||
|
spki(SECKEY_CreateSubjectPublicKeyInfo(&publicKey));
|
||||||
|
if (!spki) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
SECItem spkDER = spki->subjectPublicKey;
|
||||||
|
DER_ConvertBitString(&spkDER); // bits to bytes
|
||||||
|
return new (std::nothrow) NSSTestKeyPair(publicKeyAlg,
|
||||||
|
ByteString(spkDER.data, spkDER.len),
|
||||||
|
privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -185,21 +194,7 @@ GenerateKeyPairInner()
|
||||||
nullptr));
|
nullptr));
|
||||||
ScopedSECKEYPublicKey publicKey(publicKeyTemp);
|
ScopedSECKEYPublicKey publicKey(publicKeyTemp);
|
||||||
if (privateKey) {
|
if (privateKey) {
|
||||||
ScopedSECItem
|
return CreateTestKeyPair(RSA_PKCS1(), *publicKey, privateKey.release());
|
||||||
spkiDER(SECKEY_EncodeDERSubjectPublicKeyInfo(publicKey.get()));
|
|
||||||
if (!spkiDER) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ScopedPtr<CERTSubjectPublicKeyInfo, SECKEY_DestroySubjectPublicKeyInfo>
|
|
||||||
spki(SECKEY_CreateSubjectPublicKeyInfo(publicKey.get()));
|
|
||||||
if (!spki) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SECItem spkDER = spki->subjectPublicKey;
|
|
||||||
DER_ConvertBitString(&spkDER); // bits to bytes
|
|
||||||
return CreateTestKeyPair(ByteString(spkiDER->data, spkiDER->len),
|
|
||||||
ByteString(spkDER.data, spkDER.len),
|
|
||||||
privateKey.release());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!publicKeyTemp);
|
assert(!publicKeyTemp);
|
||||||
|
@ -251,101 +246,24 @@ GenerateDSSKeyPair()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Since it takes over 20 seconds to generate the parameters, we've
|
ByteString p(DSS_P());
|
||||||
// taken the parameters generated during one run and hard-coded them for use
|
ByteString q(DSS_Q());
|
||||||
// in all runs. The parameters were generated from this code:
|
ByteString g(DSS_G());
|
||||||
//
|
|
||||||
// PQGParams* pqgParamsTemp = nullptr;
|
|
||||||
// PQGVerify* pqgVerify = nullptr;
|
|
||||||
// if (PK11_PQG_ParamGenV2(2048u, 256u, 256u / 8u, &pqgParamsTemp,
|
|
||||||
// &pqgVerify) != SECSuccess) {
|
|
||||||
// return nullptr;
|
|
||||||
// }
|
|
||||||
// PK11_PQG_DestroyVerify(pqgVerify);
|
|
||||||
// ScopedPtr<PQGParams, PK11_PQG_DestroyParams> params(pqgParamsTemp);
|
|
||||||
|
|
||||||
static const uint8_t P[2048 / 8] = {
|
|
||||||
0xff, 0x09, 0x00, 0x0e, 0x4d, 0x8e, 0xfb, 0x6b,
|
|
||||||
0x01, 0xd9, 0xb2, 0x3a, 0x80, 0xb0, 0xf5, 0xbd,
|
|
||||||
0xe9, 0x21, 0xcf, 0x07, 0xa0, 0x6a, 0xd3, 0x9e,
|
|
||||||
0x5c, 0x0d, 0x2f, 0x13, 0x2e, 0x94, 0x41, 0x96,
|
|
||||||
0x7d, 0xed, 0x90, 0x43, 0x2a, 0x0c, 0x12, 0x75,
|
|
||||||
0xe3, 0x56, 0xa1, 0xb4, 0x59, 0xd4, 0x4f, 0xf3,
|
|
||||||
0x3f, 0x79, 0x9a, 0x7d, 0xe9, 0x51, 0xb7, 0xe2,
|
|
||||||
0x07, 0x0f, 0x51, 0xc7, 0x68, 0x2b, 0x82, 0x3c,
|
|
||||||
0xa4, 0x8c, 0xdc, 0x31, 0xe0, 0x80, 0xb3, 0x6a,
|
|
||||||
0x30, 0xd5, 0xcb, 0xc7, 0x9e, 0xe6, 0xda, 0xee,
|
|
||||||
0x92, 0x87, 0xdf, 0x85, 0x19, 0xf0, 0xe5, 0x24,
|
|
||||||
0x4b, 0xb4, 0xce, 0x69, 0xd0, 0x46, 0x08, 0x3a,
|
|
||||||
0x1f, 0xf4, 0x98, 0x43, 0x2b, 0x0f, 0xb6, 0xd7,
|
|
||||||
0xf2, 0x57, 0xac, 0x2b, 0xbb, 0x85, 0x5c, 0x67,
|
|
||||||
0xdd, 0x22, 0xab, 0x50, 0xd8, 0x69, 0x1e, 0xbe,
|
|
||||||
0xa2, 0xb6, 0x2d, 0xae, 0xbb, 0xf6, 0x27, 0x41,
|
|
||||||
0x4f, 0x92, 0x04, 0x4f, 0x99, 0x15, 0x07, 0x52,
|
|
||||||
0x22, 0xdf, 0x92, 0xea, 0xee, 0x05, 0xdc, 0xd7,
|
|
||||||
0x23, 0x3d, 0x63, 0xc1, 0xe0, 0x92, 0x3d, 0x1a,
|
|
||||||
0xbe, 0x53, 0xab, 0x5f, 0x6a, 0x8b, 0xca, 0x6c,
|
|
||||||
0x86, 0x8e, 0xe7, 0xf9, 0x15, 0x62, 0xd5, 0x33,
|
|
||||||
0xf4, 0x19, 0x3b, 0x58, 0x4e, 0xb7, 0x4f, 0xd3,
|
|
||||||
0xdd, 0x91, 0x34, 0xae, 0x55, 0x11, 0x38, 0xd9,
|
|
||||||
0x5d, 0x4a, 0xa0, 0xad, 0xf1, 0xea, 0x54, 0xf8,
|
|
||||||
0xda, 0x50, 0x6e, 0xb2, 0x94, 0xa9, 0x95, 0x58,
|
|
||||||
0x70, 0x55, 0x74, 0x3c, 0xb8, 0x57, 0xe6, 0x5a,
|
|
||||||
0x65, 0x3f, 0x4f, 0x17, 0x32, 0xb3, 0x0b, 0x09,
|
|
||||||
0xcd, 0x4f, 0x5a, 0x53, 0x04, 0xbf, 0xd7, 0x4d,
|
|
||||||
0xb4, 0x3d, 0x1a, 0x5b, 0xb8, 0x5d, 0xd9, 0x35,
|
|
||||||
0x8a, 0x56, 0x6c, 0x48, 0x1e, 0x42, 0x7b, 0x54,
|
|
||||||
0xc4, 0xbb, 0x57, 0x16, 0xb5, 0x49, 0x79, 0x1c,
|
|
||||||
0xaa, 0x90, 0x5b, 0x2b, 0x0b, 0x96, 0x92, 0x8d
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t Q[256 / 8] = {
|
|
||||||
0xd2, 0x5c, 0xab, 0xa7, 0xac, 0x92, 0x39, 0xa4,
|
|
||||||
0x20, 0xc1, 0x7d, 0x2f, 0x81, 0xb0, 0x6a, 0x81,
|
|
||||||
0xa6, 0xdc, 0xc3, 0xfa, 0xae, 0x7f, 0x78, 0x82,
|
|
||||||
0xa1, 0xc7, 0xf4, 0x59, 0x62, 0x11, 0x6c, 0x67
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t G[2048 / 8] = {
|
|
||||||
0xde, 0x50, 0x3b, 0x1d, 0xf0, 0x82, 0xa0, 0x0a,
|
|
||||||
0x80, 0x61, 0xed, 0x77, 0x8a, 0x0d, 0x04, 0xdc,
|
|
||||||
0x16, 0x03, 0x4a, 0x24, 0x3a, 0x0e, 0x44, 0x8d,
|
|
||||||
0xef, 0x94, 0x4a, 0x50, 0x5e, 0x5d, 0xa9, 0xb4,
|
|
||||||
0x19, 0x6b, 0xc8, 0x73, 0xb1, 0xc6, 0xb9, 0x61,
|
|
||||||
0xc1, 0x81, 0x9e, 0x8d, 0x8e, 0xd7, 0x74, 0x14,
|
|
||||||
0xba, 0xd2, 0x30, 0x03, 0x2d, 0xf6, 0xb4, 0xe2,
|
|
||||||
0x40, 0xdd, 0xbe, 0xe6, 0x1b, 0x1c, 0x11, 0xab,
|
|
||||||
0x80, 0x08, 0x34, 0x96, 0xe0, 0x0b, 0x4d, 0xa5,
|
|
||||||
0x3b, 0x5e, 0xee, 0xc0, 0x6d, 0xac, 0x05, 0x8d,
|
|
||||||
0x45, 0x7a, 0xb7, 0x8d, 0x22, 0x42, 0x35, 0x5e,
|
|
||||||
0x36, 0xff, 0xcf, 0x42, 0x10, 0x43, 0x07, 0x94,
|
|
||||||
0xbf, 0x59, 0xad, 0xc3, 0x10, 0xd0, 0xc1, 0xfb,
|
|
||||||
0xe3, 0x06, 0x40, 0x76, 0x88, 0xf6, 0xc5, 0x46,
|
|
||||||
0xf1, 0x3d, 0x26, 0xb8, 0xa5, 0x18, 0xd5, 0x5c,
|
|
||||||
0xe4, 0x46, 0x96, 0x3f, 0xe1, 0x90, 0x39, 0xa3,
|
|
||||||
0xa4, 0x64, 0x3c, 0xd1, 0xc6, 0x70, 0xeb, 0xeb,
|
|
||||||
0xd1, 0x7c, 0x53, 0x14, 0x2c, 0xa3, 0xdf, 0x70,
|
|
||||||
0x86, 0xbf, 0xbf, 0x08, 0xed, 0xc6, 0x54, 0xc3,
|
|
||||||
0xc6, 0xcc, 0xe5, 0xcd, 0xc5, 0x21, 0x9b, 0x07,
|
|
||||||
0xf7, 0xd5, 0x10, 0x9a, 0xd4, 0x83, 0xb6, 0x5b,
|
|
||||||
0x1c, 0x2e, 0xd1, 0x53, 0xdb, 0x53, 0x52, 0xcd,
|
|
||||||
0xda, 0x48, 0x60, 0x2c, 0x99, 0x1f, 0x00, 0xde,
|
|
||||||
0x7a, 0x45, 0xaa, 0x15, 0xb0, 0xd4, 0xfb, 0x9c,
|
|
||||||
0xf3, 0x17, 0xc9, 0x32, 0x49, 0x13, 0xf3, 0xe6,
|
|
||||||
0x73, 0x0b, 0x4e, 0x8b, 0x01, 0xf1, 0xb5, 0x9e,
|
|
||||||
0xa7, 0xa7, 0x8a, 0x46, 0xcd, 0xb7, 0xee, 0xf0,
|
|
||||||
0x0d, 0xee, 0x90, 0x2f, 0x09, 0xe1, 0x9d, 0xe9,
|
|
||||||
0x59, 0x84, 0xd6, 0xb6, 0xf1, 0xb2, 0x27, 0xc1,
|
|
||||||
0x7a, 0xd8, 0x37, 0xb8, 0x6a, 0xb9, 0xd1, 0x58,
|
|
||||||
0x78, 0xad, 0x0f, 0xa5, 0xac, 0xea, 0x79, 0x8b,
|
|
||||||
0x27, 0x79, 0xcf, 0x6c, 0x11, 0xbe, 0x9c, 0xac
|
|
||||||
};
|
|
||||||
|
|
||||||
static const PQGParams PARAMS = {
|
static const PQGParams PARAMS = {
|
||||||
nullptr,
|
nullptr,
|
||||||
{ siBuffer, const_cast<uint8_t*>(P), sizeof(P) },
|
{ siBuffer,
|
||||||
{ siBuffer, const_cast<uint8_t*>(Q), sizeof(Q) },
|
const_cast<uint8_t*>(p.data()),
|
||||||
{ siBuffer, const_cast<uint8_t*>(G), sizeof(G) }
|
static_cast<unsigned int>(p.length())
|
||||||
|
},
|
||||||
|
{ siBuffer,
|
||||||
|
const_cast<uint8_t*>(q.data()),
|
||||||
|
static_cast<unsigned int>(q.length())
|
||||||
|
},
|
||||||
|
{ siBuffer,
|
||||||
|
const_cast<uint8_t*>(g.data()),
|
||||||
|
static_cast<unsigned int>(g.length())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SECKEYPublicKey* publicKeyTemp = nullptr;
|
SECKEYPublicKey* publicKeyTemp = nullptr;
|
||||||
|
@ -357,23 +275,7 @@ GenerateDSSKeyPair()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ScopedSECKEYPublicKey publicKey(publicKeyTemp);
|
ScopedSECKEYPublicKey publicKey(publicKeyTemp);
|
||||||
|
return CreateTestKeyPair(DSS(), *publicKey, privateKey.release());
|
||||||
ScopedSECItem spkiDER(SECKEY_EncodeDERSubjectPublicKeyInfo(publicKey.get()));
|
|
||||||
if (!spkiDER) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopedPtr<CERTSubjectPublicKeyInfo, SECKEY_DestroySubjectPublicKeyInfo>
|
|
||||||
spki(SECKEY_CreateSubjectPublicKeyInfo(publicKey.get()));
|
|
||||||
if (!spki) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SECItem spkDER = spki->subjectPublicKey;
|
|
||||||
DER_ConvertBitString(&spkDER); // bits to bytes
|
|
||||||
return CreateTestKeyPair(ByteString(spkiDER->data, spkiDER->len),
|
|
||||||
ByteString(spkDER.data, spkDER.len),
|
|
||||||
privateKey.release());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result
|
Result
|
||||||
|
|
|
@ -1123,4 +1123,17 @@ CertStatus(OCSPResponseContext& context)
|
||||||
return ByteString();
|
return ByteString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const ByteString NO_UNUSED_BITS(1, 0x00);
|
||||||
|
|
||||||
|
// The SubjectPublicKeyInfo syntax is specified in RFC 5280 Section 4.1.
|
||||||
|
TestKeyPair::TestKeyPair(const TestPublicKeyAlgorithm& publicKeyAlg,
|
||||||
|
const ByteString& spk)
|
||||||
|
: publicKeyAlg(publicKeyAlg)
|
||||||
|
, subjectPublicKeyInfo(TLV(der::SEQUENCE,
|
||||||
|
publicKeyAlg.algorithmIdentifier +
|
||||||
|
TLV(der::BIT_STRING, NO_UNUSED_BITS + spk)))
|
||||||
|
, subjectPublicKey(spk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
} } } // namespace mozilla::pkix::test
|
} } } // namespace mozilla::pkix::test
|
||||||
|
|
|
@ -88,6 +88,11 @@ struct TestPublicKeyAlgorithm
|
||||||
ByteString algorithmIdentifier;
|
ByteString algorithmIdentifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ByteString DSS_P();
|
||||||
|
ByteString DSS_Q();
|
||||||
|
ByteString DSS_G();
|
||||||
|
|
||||||
|
TestPublicKeyAlgorithm DSS();
|
||||||
TestPublicKeyAlgorithm RSA_PKCS1();
|
TestPublicKeyAlgorithm RSA_PKCS1();
|
||||||
|
|
||||||
struct TestSignatureAlgorithm
|
struct TestSignatureAlgorithm
|
||||||
|
@ -267,6 +272,8 @@ class TestKeyPair
|
||||||
public:
|
public:
|
||||||
virtual ~TestKeyPair() { }
|
virtual ~TestKeyPair() { }
|
||||||
|
|
||||||
|
const TestPublicKeyAlgorithm publicKeyAlg;
|
||||||
|
|
||||||
// The DER encoding of the entire SubjectPublicKeyInfo structure. This is
|
// The DER encoding of the entire SubjectPublicKeyInfo structure. This is
|
||||||
// what is encoded in certificates.
|
// what is encoded in certificates.
|
||||||
const ByteString subjectPublicKeyInfo;
|
const ByteString subjectPublicKeyInfo;
|
||||||
|
@ -281,12 +288,7 @@ public:
|
||||||
|
|
||||||
virtual TestKeyPair* Clone() const = 0;
|
virtual TestKeyPair* Clone() const = 0;
|
||||||
protected:
|
protected:
|
||||||
TestKeyPair(const ByteString& spki, const ByteString& spk)
|
TestKeyPair(const TestPublicKeyAlgorithm& publicKeyAlg, const ByteString& spk);
|
||||||
: subjectPublicKeyInfo(spki)
|
|
||||||
, subjectPublicKey(spk)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
TestKeyPair(const TestKeyPair&) = delete;
|
TestKeyPair(const TestKeyPair&) = delete;
|
||||||
void operator=(const TestKeyPair&) = delete;
|
void operator=(const TestKeyPair&) = delete;
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче