mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-28 19:37:32 +09:00
nss: update nss to hg rev 395a93dbc02e with vc2013 patch applied
This commit is contained in:
parent
50f657b9c7
commit
b0e724dc85
84 changed files with 14198 additions and 661 deletions
|
|
@ -9,49 +9,13 @@
|
|||
#include "cpputil.h"
|
||||
#include "nss_scoped_ptrs.h"
|
||||
|
||||
#include "testvectors/curve25519-vectors.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace nss_test {
|
||||
|
||||
// <https://tools.ietf.org/html/rfc7748#section-6.1>
|
||||
const uint8_t kPkcs8[] = {
|
||||
0x30, 0x67, 0x02, 0x01, 0x00, 0x30, 0x14, 0x06, 0x07, 0x2a, 0x86, 0x48,
|
||||
0xce, 0x3d, 0x02, 0x01, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xda,
|
||||
0x47, 0x0f, 0x01, 0x04, 0x4c, 0x30, 0x4a, 0x02, 0x01, 0x01, 0x04, 0x20,
|
||||
0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72,
|
||||
0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a,
|
||||
0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a, 0xa1, 0x23, 0x03, 0x21,
|
||||
0x00, 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
|
||||
0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a,
|
||||
0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a};
|
||||
const uint8_t kSpki[] = {
|
||||
0x30, 0x39, 0x30, 0x14, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
|
||||
0x01, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xda, 0x47, 0x0f, 0x01,
|
||||
0x03, 0x21, 0x00, 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3,
|
||||
0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b,
|
||||
0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f};
|
||||
const uint8_t kSecret[] = {0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1,
|
||||
0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35, 0x0f, 0x25,
|
||||
0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33,
|
||||
0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42};
|
||||
|
||||
// A public key that's too short (31 bytes).
|
||||
const uint8_t kSpkiShort[] = {
|
||||
0x30, 0x38, 0x30, 0x14, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
|
||||
0x01, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xda, 0x47, 0x0f, 0x01,
|
||||
0x03, 0x20, 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b,
|
||||
0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78,
|
||||
0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f};
|
||||
|
||||
// A public key that's too long (33 bytes).
|
||||
const uint8_t kSpkiLong[] = {
|
||||
0x30, 0x3a, 0x30, 0x14, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
|
||||
0x01, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xda, 0x47, 0x0f, 0x01,
|
||||
0x03, 0x22, 0x00, 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3,
|
||||
0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b,
|
||||
0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f, 0x34};
|
||||
|
||||
class Pkcs11Curve25519Test : public ::testing::Test {
|
||||
class Pkcs11Curve25519Test
|
||||
: public ::testing::TestWithParam<curve25519_testvector> {
|
||||
protected:
|
||||
void Derive(const uint8_t* pkcs8, size_t pkcs8_len, const uint8_t* spki,
|
||||
size_t spki_len, const uint8_t* secret, size_t secret_len,
|
||||
|
|
@ -84,7 +48,7 @@ class Pkcs11Curve25519Test : public ::testing::Test {
|
|||
ScopedPK11SymKey symKey(PK11_PubDeriveWithKDF(
|
||||
privKey.get(), pubKey.get(), false, nullptr, nullptr, CKM_ECDH1_DERIVE,
|
||||
CKM_SHA512_HMAC, CKA_DERIVE, 0, CKD_NULL, nullptr, nullptr));
|
||||
EXPECT_EQ(expect_success, !!symKey);
|
||||
ASSERT_EQ(expect_success, !!symKey);
|
||||
|
||||
if (expect_success) {
|
||||
rv = PK11_ExtractKeyValue(symKey.get());
|
||||
|
|
@ -94,22 +58,22 @@ class Pkcs11Curve25519Test : public ::testing::Test {
|
|||
EXPECT_EQ(secret_len, keyData->len);
|
||||
EXPECT_EQ(memcmp(keyData->data, secret, secret_len), 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Derive(const curve25519_testvector testvector) {
|
||||
Derive(testvector.private_key.data(), testvector.private_key.size(),
|
||||
testvector.public_key.data(), testvector.public_key.size(),
|
||||
testvector.secret.data(), testvector.secret.size(),
|
||||
testvector.valid);
|
||||
};
|
||||
};
|
||||
|
||||
TEST_F(Pkcs11Curve25519Test, DeriveSharedSecret) {
|
||||
Derive(kPkcs8, sizeof(kPkcs8), kSpki, sizeof(kSpki), kSecret, sizeof(kSecret),
|
||||
true);
|
||||
}
|
||||
TEST_P(Pkcs11Curve25519Test, TestVectors) { Derive(GetParam()); }
|
||||
|
||||
TEST_F(Pkcs11Curve25519Test, DeriveSharedSecretShort) {
|
||||
Derive(kPkcs8, sizeof(kPkcs8), kSpkiShort, sizeof(kSpkiShort), nullptr, 0,
|
||||
false);
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(NSSTestVector, Pkcs11Curve25519Test,
|
||||
::testing::ValuesIn(kCurve25519Vectors));
|
||||
|
||||
TEST_F(Pkcs11Curve25519Test, DeriveSharedSecretLong) {
|
||||
Derive(kPkcs8, sizeof(kPkcs8), kSpkiLong, sizeof(kSpkiLong), nullptr, 0,
|
||||
false);
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(WycheproofTestVector, Pkcs11Curve25519Test,
|
||||
::testing::ValuesIn(kCurve25519WycheproofVectors));
|
||||
|
||||
} // namespace nss_test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue