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/bytestring
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/bytestring')
-rw-r--r--crypto/bytestring/bytestring_test.cc58
1 files changed, 31 insertions, 27 deletions
diff --git a/crypto/bytestring/bytestring_test.cc b/crypto/bytestring/bytestring_test.cc
index 31ee51c4..95d9b85c 100644
--- a/crypto/bytestring/bytestring_test.cc
+++ b/crypto/bytestring/bytestring_test.cc
@@ -29,6 +29,8 @@
#include "../test/scoped_types.h"
+namespace bssl {
+
static bool TestSkip() {
static const uint8_t kData[] = {1, 2, 3};
CBS data;
@@ -292,7 +294,7 @@ static bool TestCBBBasic() {
return false;
}
- ScopedOpenSSLBytes scoper(buf);
+ ScopedBytes scoper(buf);
return buf_len == sizeof(kExpected) && memcmp(buf, kExpected, buf_len) == 0;
}
@@ -337,7 +339,7 @@ static bool TestCBBFinishChild() {
CBB_cleanup(&cbb);
return false;
}
- ScopedOpenSSLBytes scoper(out_buf);
+ ScopedBytes scoper(out_buf);
return out_size == 1 && out_buf[0] == 0;
}
@@ -370,7 +372,7 @@ static bool TestCBBPrefixed() {
return false;
}
- ScopedOpenSSLBytes scoper(buf);
+ ScopedBytes scoper(buf);
return buf_len == sizeof(kExpected) && memcmp(buf, kExpected, buf_len) == 0;
}
@@ -410,7 +412,7 @@ static bool TestCBBDiscardChild() {
if (!CBB_finish(cbb.get(), &buf, &buf_len)) {
return false;
}
- ScopedOpenSSLBytes scoper(buf);
+ ScopedBytes scoper(buf);
static const uint8_t kExpected[] = {
0xaa,
@@ -456,7 +458,7 @@ static bool TestCBBMisuse() {
CBB_cleanup(&cbb);
return false;
}
- ScopedOpenSSLBytes scoper(buf);
+ ScopedBytes scoper(buf);
if (buf_len != 3 ||
memcmp(buf, "\x01\x01\x02", 3) != 0) {
@@ -480,7 +482,7 @@ static bool TestCBBASN1() {
CBB_cleanup(&cbb);
return false;
}
- ScopedOpenSSLBytes scoper(buf);
+ ScopedBytes scoper(buf);
if (buf_len != sizeof(kExpected) || memcmp(buf, kExpected, buf_len) != 0) {
return false;
@@ -555,7 +557,7 @@ static bool DoBerConvert(const char *name,
fprintf(stderr, "%s: CBS_asn1_ber_to_der failed.\n", name);
return false;
}
- ScopedOpenSSLBytes scoper(out);
+ ScopedBytes scoper(out);
if (out == NULL) {
if (ber_len != der_len ||
@@ -668,7 +670,7 @@ static bool TestImplicitString() {
int ok = CBS_get_asn1_implicit_string(&in, &out, &storage,
CBS_ASN1_CONTEXT_SPECIFIC | 0,
CBS_ASN1_OCTETSTRING);
- ScopedOpenSSLBytes scoper(storage);
+ ScopedBytes scoper(storage);
if (static_cast<bool>(ok) != test.ok) {
fprintf(stderr, "CBS_get_asn1_implicit_string unexpectedly %s\n",
@@ -747,7 +749,7 @@ static bool TestASN1Uint64() {
CBB_cleanup(&cbb);
return false;
}
- ScopedOpenSSLBytes scoper(out);
+ ScopedBytes scoper(out);
if (len != test->encoding_len || memcmp(out, test->encoding, len) != 0) {
return false;
}
@@ -797,27 +799,29 @@ static bool TestCBBReserve() {
return true;
}
+} // namespace bssl
+
int main(void) {
CRYPTO_library_init();
- if (!TestSkip() ||
- !TestGetUint() ||
- !TestGetPrefixed() ||
- !TestGetPrefixedBad() ||
- !TestGetASN1() ||
- !TestCBBBasic() ||
- !TestCBBFixed() ||
- !TestCBBFinishChild() ||
- !TestCBBMisuse() ||
- !TestCBBPrefixed() ||
- !TestCBBDiscardChild() ||
- !TestCBBASN1() ||
- !TestBerConvert() ||
- !TestImplicitString() ||
- !TestASN1Uint64() ||
- !TestGetOptionalASN1Bool() ||
- !TestZero() ||
- !TestCBBReserve()) {
+ if (!bssl::TestSkip() ||
+ !bssl::TestGetUint() ||
+ !bssl::TestGetPrefixed() ||
+ !bssl::TestGetPrefixedBad() ||
+ !bssl::TestGetASN1() ||
+ !bssl::TestCBBBasic() ||
+ !bssl::TestCBBFixed() ||
+ !bssl::TestCBBFinishChild() ||
+ !bssl::TestCBBMisuse() ||
+ !bssl::TestCBBPrefixed() ||
+ !bssl::TestCBBDiscardChild() ||
+ !bssl::TestCBBASN1() ||
+ !bssl::TestBerConvert() ||
+ !bssl::TestImplicitString() ||
+ !bssl::TestASN1Uint64() ||
+ !bssl::TestGetOptionalASN1Bool() ||
+ !bssl::TestZero() ||
+ !bssl::TestCBBReserve()) {
return 1;
}