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:
authorBrian Smith <brian@briansmith.org>2015-03-19 11:34:57 +0300
committerAdam Langley <agl@google.com>2015-04-07 03:08:23 +0300
commita91762834e410c9140d2b5ec978e7f3c4332ee3f (patch)
tree4c1f0b655382cacb7899f193c5b7360eb67c4607 /crypto/ecdsa
parent5d48b02a5b3436f42f00b1027e003899fc5bc7c1 (diff)
Implement ECDSA_SIG_new and ECDSA_SIG_free manually.
Implement ECDSA_SIG_new and ECDSA_SIG_free manually in preparation for removing all crypto/asn1 dependencies from ECDSA signature verification. Change-Id: I0e84d74fa8e757af0cfb09daef03d59f428143cc Reviewed-on: https://boringssl-review.googlesource.com/4153 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/ecdsa')
-rw-r--r--crypto/ecdsa/ecdsa_asn1.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/crypto/ecdsa/ecdsa_asn1.c b/crypto/ecdsa/ecdsa_asn1.c
index b3c6a876..f557ca77 100644
--- a/crypto/ecdsa/ecdsa_asn1.c
+++ b/crypto/ecdsa/ecdsa_asn1.c
@@ -55,6 +55,7 @@
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/ec_key.h>
+#include <openssl/mem.h>
#include "../ec/internal.h"
@@ -67,7 +68,7 @@ ASN1_SEQUENCE(ECDSA_SIG) = {
ASN1_SIMPLE(ECDSA_SIG, s, CBIGNUM),
} ASN1_SEQUENCE_END(ECDSA_SIG);
-IMPLEMENT_ASN1_FUNCTIONS_const(ECDSA_SIG);
+IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ECDSA_SIG, ECDSA_SIG, ECDSA_SIG);
size_t ECDSA_size(const EC_KEY *key) {
size_t ret, i, group_order_size;
@@ -114,3 +115,27 @@ size_t ECDSA_size(const EC_KEY *key) {
BN_clear_free(order);
return ret;
}
+
+ECDSA_SIG *ECDSA_SIG_new(void) {
+ ECDSA_SIG *sig = OPENSSL_malloc(sizeof(ECDSA_SIG));
+ if (sig == NULL) {
+ return NULL;
+ }
+ sig->r = BN_new();
+ sig->s = BN_new();
+ if (sig->r == NULL || sig->s == NULL) {
+ ECDSA_SIG_free(sig);
+ return NULL;
+ }
+ return sig;
+}
+
+void ECDSA_SIG_free(ECDSA_SIG *sig) {
+ if (sig == NULL) {
+ return;
+ }
+
+ BN_free(sig->r);
+ BN_free(sig->s);
+ OPENSSL_free(sig);
+}