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:
authorDavid Benjamin <davidben@chromium.org>2015-11-12 01:01:27 +0300
committerAdam Langley <agl@google.com>2015-11-12 01:19:36 +0300
commitef14b2d86e4ce24d7adc2d7948b5372bc3b62c33 (patch)
tree3dc8352c02389149258e3734d6a1a3655840b38e /crypto/ecdsa
parentcd24a39f1b3644da333bfcb43865ab7a6587c5cc (diff)
Remove stl_compat.h.
Chromium's toolchains may now assume C++11 library support, so we may freely use C++11 features. (Chromium's still in the process of deciding what to allow, but we use Google's style guide directly, toolchain limitations aside.) Change-Id: I1c7feb92b7f5f51d9091a4c686649fb574ac138d Reviewed-on: https://boringssl-review.googlesource.com/6465 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/ecdsa')
-rw-r--r--crypto/ecdsa/ecdsa_test.cc41
1 files changed, 18 insertions, 23 deletions
diff --git a/crypto/ecdsa/ecdsa_test.cc b/crypto/ecdsa/ecdsa_test.cc
index b916509c..5e021bdc 100644
--- a/crypto/ecdsa/ecdsa_test.cc
+++ b/crypto/ecdsa/ecdsa_test.cc
@@ -63,7 +63,6 @@
#include <openssl/rand.h>
#include "../test/scoped_types.h"
-#include "../test/stl_compat.h"
enum Api {
kEncodedApi,
@@ -118,9 +117,8 @@ static bool TestTamperedSig(FILE *out, Api api, const uint8_t *digest,
size_t buf_len = 2 * bn_len;
std::vector<uint8_t> raw_buf(buf_len);
// Pad the bignums with leading zeroes.
- if (!BN_bn2bin_padded(bssl::vector_data(&raw_buf), bn_len, ecdsa_sig->r) ||
- !BN_bn2bin_padded(bssl::vector_data(&raw_buf) + bn_len, bn_len,
- ecdsa_sig->s)) {
+ if (!BN_bn2bin_padded(raw_buf.data(), bn_len, ecdsa_sig->r) ||
+ !BN_bn2bin_padded(raw_buf.data() + bn_len, bn_len, ecdsa_sig->s)) {
return false;
}
@@ -129,18 +127,16 @@ static bool TestTamperedSig(FILE *out, Api api, const uint8_t *digest,
uint8_t dirt = raw_buf[11] ? raw_buf[11] : 1;
raw_buf[offset] ^= dirt;
// Now read the BIGNUMs back in from raw_buf.
- if (BN_bin2bn(bssl::vector_data(&raw_buf), bn_len, ecdsa_sig->r) == NULL ||
- BN_bin2bn(bssl::vector_data(&raw_buf) + bn_len, bn_len,
- ecdsa_sig->s) == NULL ||
+ if (BN_bin2bn(raw_buf.data(), bn_len, ecdsa_sig->r) == NULL ||
+ BN_bin2bn(raw_buf.data() + bn_len, bn_len, ecdsa_sig->s) == NULL ||
!VerifyECDSASig(api, digest, digest_len, ecdsa_sig, eckey, 0)) {
return false;
}
// Sanity check: Undo the modification and verify signature.
raw_buf[offset] ^= dirt;
- if (BN_bin2bn(bssl::vector_data(&raw_buf), bn_len, ecdsa_sig->r) == NULL ||
- BN_bin2bn(bssl::vector_data(&raw_buf) + bn_len, bn_len,
- ecdsa_sig->s) == NULL ||
+ if (BN_bin2bn(raw_buf.data(), bn_len, ecdsa_sig->r) == NULL ||
+ BN_bin2bn(raw_buf.data() + bn_len, bn_len, ecdsa_sig->s) == NULL ||
!VerifyECDSASig(api, digest, digest_len, ecdsa_sig, eckey, 1)) {
return false;
}
@@ -221,8 +217,7 @@ static bool TestBuiltin(FILE *out) {
// Create a signature.
unsigned sig_len = ECDSA_size(eckey.get());
std::vector<uint8_t> signature(sig_len);
- if (!ECDSA_sign(0, digest, 20, bssl::vector_data(&signature), &sig_len,
- eckey.get())) {
+ if (!ECDSA_sign(0, digest, 20, signature.data(), &sig_len, eckey.get())) {
fprintf(out, " failed\n");
return false;
}
@@ -230,32 +225,32 @@ static bool TestBuiltin(FILE *out) {
fprintf(out, ".");
fflush(out);
// Verify the signature.
- if (!ECDSA_verify(0, digest, 20, bssl::vector_data(&signature),
- signature.size(), eckey.get())) {
+ if (!ECDSA_verify(0, digest, 20, signature.data(), signature.size(),
+ eckey.get())) {
fprintf(out, " failed\n");
return false;
}
fprintf(out, ".");
fflush(out);
// Verify the signature with the wrong key.
- if (ECDSA_verify(0, digest, 20, bssl::vector_data(&signature),
- signature.size(), wrong_eckey.get())) {
+ if (ECDSA_verify(0, digest, 20, signature.data(), signature.size(),
+ wrong_eckey.get())) {
fprintf(out, " failed\n");
return false;
}
fprintf(out, ".");
fflush(out);
// Verify the signature using the wrong digest.
- if (ECDSA_verify(0, wrong_digest, 20, bssl::vector_data(&signature),
- signature.size(), eckey.get())) {
+ if (ECDSA_verify(0, wrong_digest, 20, signature.data(), signature.size(),
+ eckey.get())) {
fprintf(out, " failed\n");
return false;
}
fprintf(out, ".");
fflush(out);
// Verify a truncated signature.
- if (ECDSA_verify(0, digest, 20, bssl::vector_data(&signature),
- signature.size() - 1, eckey.get())) {
+ if (ECDSA_verify(0, digest, 20, signature.data(), signature.size() - 1,
+ eckey.get())) {
fprintf(out, " failed\n");
return false;
}
@@ -263,7 +258,7 @@ static bool TestBuiltin(FILE *out) {
fflush(out);
// Verify a tampered signature.
ScopedECDSA_SIG ecdsa_sig(ECDSA_SIG_from_bytes(
- bssl::vector_data(&signature), signature.size()));
+ signature.data(), signature.size()));
if (!ecdsa_sig ||
!TestTamperedSig(out, kEncodedApi, digest, 20, ecdsa_sig.get(),
eckey.get(), order.get())) {
@@ -327,8 +322,8 @@ static bool TestECDSA_SIG_max_len(size_t order_len) {
return false;
}
std::vector<uint8_t> bytes(order_len, 0xff);
- if (!BN_bin2bn(bssl::vector_data(&bytes), bytes.size(), sig->r) ||
- !BN_bin2bn(bssl::vector_data(&bytes), bytes.size(), sig->s)) {
+ if (!BN_bin2bn(bytes.data(), bytes.size(), sig->r) ||
+ !BN_bin2bn(bytes.data(), bytes.size(), sig->s)) {
return false;
}
/* Serialize it. */