2014-06-20 20:00:00 +01:00
|
|
|
/* ====================================================================
|
|
|
|
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3. All advertising materials mentioning features or use of this
|
|
|
|
* software must display the following acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
|
|
|
*
|
|
|
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* prior written permission. For written permission, please contact
|
|
|
|
* openssl-core@OpenSSL.org.
|
|
|
|
*
|
|
|
|
* 5. Products derived from this software may not be called "OpenSSL"
|
|
|
|
* nor may "OpenSSL" appear in their names without prior written
|
|
|
|
* permission of the OpenSSL Project.
|
|
|
|
*
|
|
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
|
|
|
* acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
|
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
|
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
* ====================================================================
|
|
|
|
*
|
|
|
|
* This product includes cryptographic software written by Eric Young
|
|
|
|
* (eay@cryptsoft.com). This product includes software written by Tim
|
|
|
|
* Hudson (tjh@cryptsoft.com). */
|
|
|
|
|
|
|
|
#include <openssl/ecdsa.h>
|
|
|
|
|
|
|
|
#include <openssl/bn.h>
|
2014-09-12 00:11:15 +01:00
|
|
|
#include <openssl/crypto.h>
|
2014-06-20 20:00:00 +01:00
|
|
|
#include <openssl/ec.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#include <openssl/mem.h>
|
|
|
|
#include <openssl/obj.h>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
|
2015-04-13 21:34:52 +01:00
|
|
|
enum api_t {
|
2015-03-15 04:42:41 +00:00
|
|
|
encoded_api,
|
|
|
|
raw_api,
|
|
|
|
};
|
|
|
|
|
2015-03-15 04:16:32 +00:00
|
|
|
/* verify_ecdsa_sig returns 1 on success, 0 on failure. */
|
2015-03-15 04:42:41 +00:00
|
|
|
static int verify_ecdsa_sig(enum api_t api, const uint8_t *digest,
|
|
|
|
size_t digest_len, const ECDSA_SIG *ecdsa_sig,
|
|
|
|
EC_KEY *eckey, int expected_result) {
|
|
|
|
int actual_result;
|
2014-06-20 20:00:00 +01:00
|
|
|
|
2015-03-15 04:42:41 +00:00
|
|
|
switch (api) {
|
|
|
|
case encoded_api: {
|
|
|
|
int sig_len = i2d_ECDSA_SIG(ecdsa_sig, NULL);
|
|
|
|
if (sig_len <= 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
uint8_t *signature = OPENSSL_malloc(sig_len);
|
|
|
|
if (signature == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
uint8_t *sig_ptr = signature;
|
|
|
|
sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr);
|
|
|
|
if (sig_len <= 0) {
|
|
|
|
OPENSSL_free(signature);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
actual_result = ECDSA_verify(0, digest, digest_len, signature, sig_len,
|
2015-03-15 04:16:32 +00:00
|
|
|
eckey);
|
2015-03-15 04:42:41 +00:00
|
|
|
OPENSSL_free(signature);
|
|
|
|
break;
|
|
|
|
}
|
2015-03-15 04:16:32 +00:00
|
|
|
|
2015-03-15 04:42:41 +00:00
|
|
|
case raw_api:
|
|
|
|
actual_result = ECDSA_do_verify(digest, digest_len, ecdsa_sig, eckey);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return expected_result == actual_result;
|
2015-03-15 04:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test_tampered_sig verifies that signature verification fails when a valid
|
|
|
|
* signature is tampered with. |ecdsa_sig| must be a valid signature, which
|
|
|
|
* will be modified. test_tampered_sig returns 1 on success, 0 on failure. */
|
2015-03-15 04:42:41 +00:00
|
|
|
static int test_tampered_sig(FILE *out, enum api_t api, const uint8_t *digest,
|
2015-03-15 04:16:32 +00:00
|
|
|
size_t digest_len, ECDSA_SIG *ecdsa_sig,
|
|
|
|
EC_KEY *eckey, const BIGNUM *order) {
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Modify a single byte of the signature: to ensure we don't
|
|
|
|
* garble the ASN1 structure, we read the raw signature and
|
|
|
|
* modify a byte in one of the bignums directly. */
|
|
|
|
|
|
|
|
/* Store the two BIGNUMs in raw_buf. */
|
|
|
|
size_t r_len = BN_num_bytes(ecdsa_sig->r);
|
|
|
|
size_t s_len = BN_num_bytes(ecdsa_sig->s);
|
|
|
|
size_t bn_len = BN_num_bytes(order);
|
|
|
|
if (r_len > bn_len || s_len > bn_len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
size_t buf_len = 2 * bn_len;
|
|
|
|
uint8_t *raw_buf = OPENSSL_malloc(buf_len);
|
|
|
|
if (raw_buf == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Pad the bignums with leading zeroes. */
|
|
|
|
if (!BN_bn2bin_padded(raw_buf, bn_len, ecdsa_sig->r) ||
|
|
|
|
!BN_bn2bin_padded(raw_buf + bn_len, bn_len, ecdsa_sig->s)) {
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Modify a single byte in the buffer. */
|
|
|
|
size_t offset = raw_buf[10] % buf_len;
|
|
|
|
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(raw_buf, bn_len, ecdsa_sig->r) == NULL ||
|
|
|
|
BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL ||
|
2015-03-15 04:42:41 +00:00
|
|
|
!verify_ecdsa_sig(api, digest, digest_len, ecdsa_sig, eckey, 0)) {
|
2015-03-15 04:16:32 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sanity check: Undo the modification and verify signature. */
|
|
|
|
raw_buf[offset] ^= dirt;
|
|
|
|
if (BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL ||
|
|
|
|
BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL ||
|
2015-03-15 04:42:41 +00:00
|
|
|
!verify_ecdsa_sig(api, digest, digest_len, ecdsa_sig, eckey, 1)) {
|
2015-03-15 04:16:32 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
err:
|
|
|
|
if (raw_buf) {
|
|
|
|
OPENSSL_free(raw_buf);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_builtin(FILE *out) {
|
2014-06-20 20:00:00 +01:00
|
|
|
size_t n = 0;
|
|
|
|
EC_KEY *eckey = NULL, *wrong_eckey = NULL;
|
|
|
|
EC_GROUP *group;
|
2014-11-10 22:06:33 +00:00
|
|
|
BIGNUM *order = NULL;
|
2014-06-20 20:00:00 +01:00
|
|
|
ECDSA_SIG *ecdsa_sig = NULL;
|
2015-03-15 04:16:32 +00:00
|
|
|
uint8_t digest[20], wrong_digest[20];
|
|
|
|
uint8_t *signature = NULL;
|
2014-06-20 20:00:00 +01:00
|
|
|
int nid, ret = 0;
|
|
|
|
|
|
|
|
/* fill digest values with some random data */
|
2014-12-16 12:48:10 +00:00
|
|
|
if (!RAND_bytes(digest, 20) || !RAND_bytes(wrong_digest, 20)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, "ERROR: unable to get random data\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
|
2014-11-10 22:06:33 +00:00
|
|
|
order = BN_new();
|
|
|
|
if (order == NULL) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
|
2015-03-15 04:42:41 +00:00
|
|
|
/* Create and verify ecdsa signatures with every available curve. */
|
|
|
|
fputs("\ntesting ECDSA_sign(), ECDSA_verify(), ECDSA_do_sign(), and "
|
|
|
|
"ECDSA_do_verify() with some internal curves:\n", out);
|
2014-06-20 20:00:00 +01:00
|
|
|
|
2015-03-02 01:47:32 +00:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
int nid;
|
|
|
|
const char *name;
|
|
|
|
} kCurves[] = {
|
|
|
|
{ NID_secp224r1, "secp224r1" },
|
|
|
|
{ NID_X9_62_prime256v1, "secp256r1" },
|
|
|
|
{ NID_secp384r1, "secp384r1" },
|
|
|
|
{ NID_secp521r1, "secp521r1" },
|
|
|
|
{ NID_undef, NULL }
|
|
|
|
};
|
2015-03-15 04:16:32 +00:00
|
|
|
|
2014-06-20 20:00:00 +01:00
|
|
|
/* now create and verify a signature for every curve */
|
2015-03-02 01:47:32 +00:00
|
|
|
for (n = 0; kCurves[n].nid != NID_undef; n++) {
|
2014-06-20 20:00:00 +01:00
|
|
|
|
2015-03-02 01:47:32 +00:00
|
|
|
nid = kCurves[n].nid;
|
2014-06-20 20:00:00 +01:00
|
|
|
/* create new ecdsa key (== EC_KEY) */
|
|
|
|
eckey = EC_KEY_new();
|
|
|
|
if (eckey == NULL) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
group = EC_GROUP_new_by_curve_name(nid);
|
|
|
|
if (group == NULL) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
if (!EC_KEY_set_group(eckey, group)) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
EC_GROUP_free(group);
|
2014-11-10 22:06:33 +00:00
|
|
|
if (!EC_GROUP_get_order(EC_KEY_get0_group(eckey), order, NULL)) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
if (BN_num_bits(order) < 160) {
|
2014-06-20 20:00:00 +01:00
|
|
|
/* Too small to test. */
|
|
|
|
EC_KEY_free(eckey);
|
|
|
|
eckey = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-03-02 01:47:32 +00:00
|
|
|
fprintf(out, "%s: ", kCurves[n].name);
|
2014-06-20 20:00:00 +01:00
|
|
|
/* create key */
|
|
|
|
if (!EC_KEY_generate_key(eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
/* create second key */
|
|
|
|
wrong_eckey = EC_KEY_new();
|
|
|
|
if (wrong_eckey == NULL) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
group = EC_GROUP_new_by_curve_name(nid);
|
|
|
|
if (group == NULL) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-15 04:16:32 +00:00
|
|
|
if (!EC_KEY_set_group(wrong_eckey, group)) {
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
EC_GROUP_free(group);
|
|
|
|
if (!EC_KEY_generate_key(wrong_eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2014-06-20 20:00:00 +01:00
|
|
|
/* check key */
|
|
|
|
if (!EC_KEY_check_key(eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2015-03-15 04:42:41 +00:00
|
|
|
|
|
|
|
/* Test ASN.1-encoded signatures. */
|
|
|
|
/* Create a signature. */
|
|
|
|
unsigned sig_len = ECDSA_size(eckey);
|
2014-06-20 20:00:00 +01:00
|
|
|
signature = OPENSSL_malloc(sig_len);
|
|
|
|
if (signature == NULL) {
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
if (!ECDSA_sign(0, digest, 20, signature, &sig_len, eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2014-06-20 20:00:00 +01:00
|
|
|
/* verify signature */
|
2015-03-15 04:16:32 +00:00
|
|
|
if (!ECDSA_verify(0, digest, 20, signature, sig_len, eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2014-06-20 20:00:00 +01:00
|
|
|
/* verify signature with the wrong key */
|
2015-03-15 04:16:32 +00:00
|
|
|
if (ECDSA_verify(0, digest, 20, signature, sig_len, wrong_eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2014-06-20 20:00:00 +01:00
|
|
|
/* wrong digest */
|
2015-03-15 04:16:32 +00:00
|
|
|
if (ECDSA_verify(0, wrong_digest, 20, signature, sig_len, eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2014-06-20 20:00:00 +01:00
|
|
|
/* wrong length */
|
2015-03-15 04:16:32 +00:00
|
|
|
if (ECDSA_verify(0, digest, 20, signature, sig_len - 1, eckey)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2015-03-15 04:42:41 +00:00
|
|
|
/* Verify a tampered signature. */
|
|
|
|
const uint8_t *sig_ptr = signature;
|
2014-06-20 20:00:00 +01:00
|
|
|
ecdsa_sig = d2i_ECDSA_SIG(NULL, &sig_ptr, sig_len);
|
|
|
|
if (ecdsa_sig == NULL) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-15 04:42:41 +00:00
|
|
|
if (!test_tampered_sig(out, encoded_api, digest, 20, ecdsa_sig, eckey,
|
|
|
|
order)) {
|
|
|
|
fprintf(out, " failed\n");
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2015-04-15 20:28:16 +01:00
|
|
|
ECDSA_SIG_free(ecdsa_sig);
|
|
|
|
ecdsa_sig = NULL;
|
2015-03-15 04:42:41 +00:00
|
|
|
OPENSSL_free(signature);
|
|
|
|
signature = NULL;
|
|
|
|
|
|
|
|
/* Test ECDSA_SIG signing and verification. */
|
|
|
|
/* Create a signature. */
|
|
|
|
ecdsa_sig = ECDSA_do_sign(digest, 20, eckey);
|
|
|
|
if (!ecdsa_sig) {
|
|
|
|
fprintf(out, " failed\n");
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
|
|
|
/* Verify the signature using the correct key. */
|
|
|
|
if (!ECDSA_do_verify(digest, 20, ecdsa_sig, eckey)) {
|
|
|
|
fprintf(out, " failed\n");
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
|
|
|
/* Verify the signature with the wrong key. */
|
|
|
|
if (ECDSA_do_verify(digest, 20, ecdsa_sig, wrong_eckey)) {
|
|
|
|
fprintf(out, " failed\n");
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
|
|
|
/* Verify the signature using the wrong digest. */
|
|
|
|
if (ECDSA_do_verify(wrong_digest, 20, ecdsa_sig, eckey)) {
|
|
|
|
fprintf(out, " failed\n");
|
|
|
|
goto builtin_err;
|
|
|
|
}
|
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
|
|
|
/* Verify a tampered signature. */
|
|
|
|
if (!test_tampered_sig(out, raw_api, digest, 20, ecdsa_sig, eckey, order)) {
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " failed\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
goto builtin_err;
|
|
|
|
}
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, ".");
|
|
|
|
fflush(out);
|
2014-06-20 20:00:00 +01:00
|
|
|
|
2015-03-12 03:36:41 +00:00
|
|
|
fprintf(out, " ok\n");
|
2014-06-20 20:00:00 +01:00
|
|
|
/* cleanup */
|
|
|
|
/* clean bogus errors */
|
|
|
|
ERR_clear_error();
|
|
|
|
EC_KEY_free(eckey);
|
|
|
|
eckey = NULL;
|
|
|
|
EC_KEY_free(wrong_eckey);
|
|
|
|
wrong_eckey = NULL;
|
|
|
|
ECDSA_SIG_free(ecdsa_sig);
|
|
|
|
ecdsa_sig = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
builtin_err:
|
2014-11-10 22:06:33 +00:00
|
|
|
if (eckey) {
|
2014-06-20 20:00:00 +01:00
|
|
|
EC_KEY_free(eckey);
|
2014-11-10 22:06:33 +00:00
|
|
|
}
|
|
|
|
if (order) {
|
|
|
|
BN_free(order);
|
|
|
|
}
|
|
|
|
if (wrong_eckey) {
|
2014-06-20 20:00:00 +01:00
|
|
|
EC_KEY_free(wrong_eckey);
|
2014-11-10 22:06:33 +00:00
|
|
|
}
|
|
|
|
if (ecdsa_sig) {
|
2014-06-20 20:00:00 +01:00
|
|
|
ECDSA_SIG_free(ecdsa_sig);
|
2014-11-10 22:06:33 +00:00
|
|
|
}
|
|
|
|
if (signature) {
|
2014-06-20 20:00:00 +01:00
|
|
|
OPENSSL_free(signature);
|
2014-11-10 22:06:33 +00:00
|
|
|
}
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
int ret = 1;
|
|
|
|
|
2014-09-12 00:11:15 +01:00
|
|
|
CRYPTO_library_init();
|
2014-06-20 20:00:00 +01:00
|
|
|
ERR_load_crypto_strings();
|
|
|
|
|
2015-03-12 03:36:41 +00:00
|
|
|
if (!test_builtin(stdout)) {
|
2014-06-20 20:00:00 +01:00
|
|
|
goto err;
|
2015-02-11 06:17:18 +00:00
|
|
|
}
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
err:
|
2015-02-11 06:17:18 +00:00
|
|
|
if (ret) {
|
2015-03-12 03:36:41 +00:00
|
|
|
printf("\nECDSA test failed\n");
|
2015-02-11 06:17:18 +00:00
|
|
|
} else {
|
2015-03-12 03:36:41 +00:00
|
|
|
printf("\nPASS\n");
|
2015-02-11 06:17:18 +00:00
|
|
|
}
|
|
|
|
if (ret) {
|
2015-03-12 03:36:41 +00:00
|
|
|
ERR_print_errors_fp(stdout);
|
2015-02-11 06:17:18 +00:00
|
|
|
}
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|