Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2016-07-12 00:07:19 +0300
committerDavid Benjamin <davidben@google.com>2016-07-12 02:04:52 +0300
commit09feb0f3d95a2bc58ce0faaf14256d3bd30f52a4 (patch)
treec5d03846c2bffc42b9ab9bd6b6e30e044d7962b6 /crypto/rsa
parent09eb655e5cb202878b831eadb30c92ab24960d4a (diff)
Move C++ helpers into |bssl| namespace.
We currently have the situation where the |tool| and |bssl_shim| code includes scoped_types.h from crypto/test and ssl/test. That's weird and shouldn't happen. Also, our C++ consumers might quite like to have access to the scoped types. Thus this change moves some of the template code to base.h and puts it all in a |bssl| namespace to prepare for scattering these types into their respective headers. In order that all the existing test code be able to access these types, it's all moved into the same namespace. Change-Id: I3207e29474dc5fcc344ace43119df26dae04eabb Reviewed-on: https://boringssl-review.googlesource.com/8730 Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto/rsa')
-rw-r--r--crypto/rsa/rsa_test.cc50
1 files changed, 27 insertions, 23 deletions
diff --git a/crypto/rsa/rsa_test.cc b/crypto/rsa/rsa_test.cc
index 62177a4c..5307f2cb 100644
--- a/crypto/rsa/rsa_test.cc
+++ b/crypto/rsa/rsa_test.cc
@@ -523,6 +523,8 @@ static const uint8_t kExponent1RSAKey[] = {
0xdd, 0x02, 0x01, 0x01,
};
+namespace bssl {
+
static bool TestRSA(const uint8_t *der, size_t der_len,
const uint8_t *oaep_ciphertext,
size_t oaep_ciphertext_len) {
@@ -855,7 +857,7 @@ static bool TestASN1() {
if (!RSA_private_key_to_bytes(&der, &der_len, rsa.get())) {
return false;
}
- ScopedOpenSSLBytes delete_der(der);
+ ScopedBytes delete_der(der);
if (der_len != sizeof(kKey1) - 1 || memcmp(der, kKey1, der_len) != 0) {
return false;
}
@@ -878,7 +880,7 @@ static bool TestASN1() {
if (!RSA_public_key_to_bytes(&der2, &der2_len, rsa.get())) {
return false;
}
- ScopedOpenSSLBytes delete_der2(der2);
+ ScopedBytes delete_der2(der2);
if (der_len != der2_len || memcmp(der, der2, der_len) != 0) {
return false;
}
@@ -922,30 +924,32 @@ static bool TestBadExponent() {
return true;
}
+} // namespace bssl
+
int main(int argc, char *argv[]) {
CRYPTO_library_init();
- if (!TestRSA(kKey1, sizeof(kKey1) - 1, kOAEPCiphertext1,
- sizeof(kOAEPCiphertext1) - 1) ||
- !TestRSA(kKey2, sizeof(kKey2) - 1, kOAEPCiphertext2,
- sizeof(kOAEPCiphertext2) - 1) ||
- !TestRSA(kKey3, sizeof(kKey3) - 1, kOAEPCiphertext3,
- sizeof(kOAEPCiphertext3) - 1) ||
- !TestOnlyDGiven() ||
- !TestRecoverCRTParams() ||
- !TestBadKey() ||
- !TestMultiPrimeKey(2, kTwoPrimeKey, sizeof(kTwoPrimeKey) - 1,
- kTwoPrimeEncryptedMessage,
- sizeof(kTwoPrimeEncryptedMessage)) ||
- !TestMultiPrimeKey(3, kThreePrimeKey, sizeof(kThreePrimeKey) - 1,
- kThreePrimeEncryptedMessage,
- sizeof(kThreePrimeEncryptedMessage)) ||
- !TestMultiPrimeKey(6, kSixPrimeKey, sizeof(kSixPrimeKey) - 1,
- kSixPrimeEncryptedMessage,
- sizeof(kSixPrimeEncryptedMessage)) ||
- !TestMultiPrimeKeygen() ||
- !TestASN1() ||
- !TestBadExponent()) {
+ if (!bssl::TestRSA(kKey1, sizeof(kKey1) - 1, kOAEPCiphertext1,
+ sizeof(kOAEPCiphertext1) - 1) ||
+ !bssl::TestRSA(kKey2, sizeof(kKey2) - 1, kOAEPCiphertext2,
+ sizeof(kOAEPCiphertext2) - 1) ||
+ !bssl::TestRSA(kKey3, sizeof(kKey3) - 1, kOAEPCiphertext3,
+ sizeof(kOAEPCiphertext3) - 1) ||
+ !bssl::TestOnlyDGiven() ||
+ !bssl::TestRecoverCRTParams() ||
+ !bssl::TestBadKey() ||
+ !bssl::TestMultiPrimeKey(2, kTwoPrimeKey, sizeof(kTwoPrimeKey) - 1,
+ kTwoPrimeEncryptedMessage,
+ sizeof(kTwoPrimeEncryptedMessage)) ||
+ !bssl::TestMultiPrimeKey(3, kThreePrimeKey, sizeof(kThreePrimeKey) - 1,
+ kThreePrimeEncryptedMessage,
+ sizeof(kThreePrimeEncryptedMessage)) ||
+ !bssl::TestMultiPrimeKey(6, kSixPrimeKey, sizeof(kSixPrimeKey) - 1,
+ kSixPrimeEncryptedMessage,
+ sizeof(kSixPrimeEncryptedMessage)) ||
+ !bssl::TestMultiPrimeKeygen() ||
+ !bssl::TestASN1() ||
+ !bssl::TestBadExponent()) {
return 1;
}