remove crypto/ecdsa
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
8c6ef7869a
commit
f84f31fc36
@ -140,7 +140,7 @@ SDIRS= \
|
|||||||
objects \
|
objects \
|
||||||
md2 md4 md5 sha mdc2 hmac ripemd whrlpool \
|
md2 md4 md5 sha mdc2 hmac ripemd whrlpool \
|
||||||
des aes rc2 rc4 rc5 idea bf cast camellia seed modes \
|
des aes rc2 rc4 rc5 idea bf cast camellia seed modes \
|
||||||
bn ec rsa dsa ecdsa dh dso engine \
|
bn ec rsa dsa dh dso engine \
|
||||||
buffer bio stack lhash rand err \
|
buffer bio stack lhash rand err \
|
||||||
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui \
|
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui \
|
||||||
cms pqueue ts jpake srp store cmac ct async
|
cms pqueue ts jpake srp store cmac ct async
|
||||||
|
@ -1,102 +0,0 @@
|
|||||||
#
|
|
||||||
# crypto/ecdsa/Makefile
|
|
||||||
#
|
|
||||||
|
|
||||||
DIR= ecdsa
|
|
||||||
TOP= ../..
|
|
||||||
CC= cc
|
|
||||||
INCLUDES= -I.. -I$(TOP) -I../../include
|
|
||||||
CFLAG=-g -Wall
|
|
||||||
MAKEFILE= Makefile
|
|
||||||
AR= ar r
|
|
||||||
|
|
||||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
|
||||||
|
|
||||||
GENERAL=Makefile
|
|
||||||
|
|
||||||
LIB=$(TOP)/libcrypto.a
|
|
||||||
LIBSRC= ecs_lib.c ecs_err.c
|
|
||||||
|
|
||||||
LIBOBJ= ecs_lib.o ecs_err.o
|
|
||||||
|
|
||||||
SRC= $(LIBSRC)
|
|
||||||
|
|
||||||
HEADER= ecs_locl.h
|
|
||||||
|
|
||||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
|
||||||
|
|
||||||
top:
|
|
||||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
|
||||||
|
|
||||||
all: lib
|
|
||||||
|
|
||||||
lib: $(LIBOBJ)
|
|
||||||
$(AR) $(LIB) $(LIBOBJ)
|
|
||||||
$(RANLIB) $(LIB) || echo Never mind.
|
|
||||||
@touch lib
|
|
||||||
|
|
||||||
files:
|
|
||||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
|
||||||
|
|
||||||
tags:
|
|
||||||
ctags $(SRC)
|
|
||||||
|
|
||||||
tests:
|
|
||||||
|
|
||||||
lint:
|
|
||||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
|
||||||
|
|
||||||
update: depend
|
|
||||||
|
|
||||||
depend:
|
|
||||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
|
||||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
|
||||||
|
|
||||||
dclean:
|
|
||||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
|
||||||
mv -f Makefile.new $(MAKEFILE)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
|
||||||
|
|
||||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
|
||||||
|
|
||||||
ecs_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
|
||||||
ecs_asn1.o: ../../include/openssl/symhacks.h ecs_asn1.c ecs_locl.h
|
|
||||||
ecs_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
|
||||||
ecs_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
|
||||||
ecs_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdsa.h
|
|
||||||
ecs_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
|
||||||
ecs_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
|
||||||
ecs_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
|
||||||
ecs_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
|
||||||
ecs_err.o: ecs_err.c
|
|
||||||
ecs_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
|
||||||
ecs_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
|
|
||||||
ecs_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
|
||||||
ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
|
||||||
ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
|
||||||
ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
|
||||||
ecs_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
|
||||||
ecs_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
|
||||||
ecs_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
|
||||||
ecs_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
|
||||||
ecs_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
|
||||||
ecs_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
|
||||||
ecs_lib.o: ../../include/openssl/x509_vfy.h ecs_lib.c ecs_locl.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/opensslconf.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
|
|
||||||
ecs_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
|
||||||
ecs_ossl.o: ecs_locl.h ecs_ossl.c
|
|
@ -1,105 +0,0 @@
|
|||||||
/* crypto/ecdsa/ecs_err.c */
|
|
||||||
/* ====================================================================
|
|
||||||
* Copyright (c) 1999-2015 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).
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
|
||||||
* made to it will be overwritten when the script next updates this file,
|
|
||||||
* only reason strings will be preserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/ecdsa.h>
|
|
||||||
|
|
||||||
/* BEGIN ERROR CODES */
|
|
||||||
#ifndef OPENSSL_NO_ERR
|
|
||||||
|
|
||||||
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDSA,func,0)
|
|
||||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDSA,0,reason)
|
|
||||||
|
|
||||||
static ERR_STRING_DATA ECDSA_str_functs[] = {
|
|
||||||
{ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_new_method"},
|
|
||||||
{ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN), "ECDSA_do_sign"},
|
|
||||||
{ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY), "ECDSA_do_verify"},
|
|
||||||
{ERR_FUNC(ECDSA_F_ECDSA_METHOD_NEW), "ECDSA_METHOD_new"},
|
|
||||||
{ERR_FUNC(ECDSA_F_ECDSA_SIGN_SETUP), "ECDSA_sign_setup"},
|
|
||||||
{0, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static ERR_STRING_DATA ECDSA_str_reasons[] = {
|
|
||||||
{ERR_REASON(ECDSA_R_BAD_SIGNATURE), "bad signature"},
|
|
||||||
{ERR_REASON(ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),
|
|
||||||
"data too large for key size"},
|
|
||||||
{ERR_REASON(ECDSA_R_ERR_EC_LIB), "err ec lib"},
|
|
||||||
{ERR_REASON(ECDSA_R_MISSING_PARAMETERS), "missing parameters"},
|
|
||||||
{ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES), "need new setup values"},
|
|
||||||
{ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),
|
|
||||||
"random number generation failed"},
|
|
||||||
{ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED), "signature malloc failed"},
|
|
||||||
{0, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ERR_load_ECDSA_strings(void)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_ERR
|
|
||||||
|
|
||||||
if (ERR_func_error_string(ECDSA_str_functs[0].error) == NULL) {
|
|
||||||
ERR_load_strings(0, ECDSA_str_functs);
|
|
||||||
ERR_load_strings(0, ECDSA_str_reasons);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -1,311 +0,0 @@
|
|||||||
/* crypto/ecdsa/ecs_lib.c */
|
|
||||||
/* ====================================================================
|
|
||||||
* 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 <string.h>
|
|
||||||
#include "ecs_locl.h"
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
# include <openssl/engine.h>
|
|
||||||
#endif
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/bn.h>
|
|
||||||
|
|
||||||
static const ECDSA_METHOD *default_ECDSA_method = NULL;
|
|
||||||
|
|
||||||
static void *ecdsa_data_new(void);
|
|
||||||
static void *ecdsa_data_dup(void *);
|
|
||||||
static void ecdsa_data_free(void *);
|
|
||||||
|
|
||||||
void ECDSA_set_default_method(const ECDSA_METHOD *meth)
|
|
||||||
{
|
|
||||||
default_ECDSA_method = meth;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ECDSA_METHOD *ECDSA_get_default_method(void)
|
|
||||||
{
|
|
||||||
return default_ECDSA_method;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *ecdsa;
|
|
||||||
|
|
||||||
ecdsa = ecdsa_check(eckey);
|
|
||||||
|
|
||||||
if (ecdsa == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
if (ecdsa->engine) {
|
|
||||||
ENGINE_finish(ecdsa->engine);
|
|
||||||
ecdsa->engine = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ecdsa->meth = meth;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *ret;
|
|
||||||
|
|
||||||
ret = OPENSSL_malloc(sizeof(*ret));
|
|
||||||
if (ret == NULL) {
|
|
||||||
ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->init = NULL;
|
|
||||||
|
|
||||||
ret->meth = ECDSA_get_default_method();
|
|
||||||
ret->engine = engine;
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
if (!ret->engine)
|
|
||||||
ret->engine = ENGINE_get_default_ECDSA();
|
|
||||||
if (ret->engine) {
|
|
||||||
ret->meth = ENGINE_get_ECDSA(ret->engine);
|
|
||||||
if (!ret->meth) {
|
|
||||||
ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_ENGINE_LIB);
|
|
||||||
ENGINE_finish(ret->engine);
|
|
||||||
OPENSSL_free(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret->flags = ret->meth->flags;
|
|
||||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ecdsa_data_new(void)
|
|
||||||
{
|
|
||||||
return (void *)ECDSA_DATA_new_method(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ecdsa_data_dup(void *data)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *r = (ECDSA_DATA *)data;
|
|
||||||
|
|
||||||
/* XXX: dummy operation */
|
|
||||||
if (r == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return ecdsa_data_new();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ecdsa_data_free(void *data)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *r = (ECDSA_DATA *)data;
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
if (r->engine)
|
|
||||||
ENGINE_finish(r->engine);
|
|
||||||
#endif
|
|
||||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data);
|
|
||||||
|
|
||||||
OPENSSL_clear_free((void *)r, sizeof(ECDSA_DATA));
|
|
||||||
}
|
|
||||||
|
|
||||||
ECDSA_DATA *ecdsa_check(EC_KEY *key)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *ecdsa_data;
|
|
||||||
|
|
||||||
void *data = EC_KEY_get_key_method_data(key, ecdsa_data_dup,
|
|
||||||
ecdsa_data_free, ecdsa_data_free);
|
|
||||||
if (data == NULL) {
|
|
||||||
ecdsa_data = (ECDSA_DATA *)ecdsa_data_new();
|
|
||||||
if (ecdsa_data == NULL)
|
|
||||||
return NULL;
|
|
||||||
data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data,
|
|
||||||
ecdsa_data_dup, ecdsa_data_free,
|
|
||||||
ecdsa_data_free);
|
|
||||||
if (data != NULL) {
|
|
||||||
/*
|
|
||||||
* Another thread raced us to install the key_method data and
|
|
||||||
* won.
|
|
||||||
*/
|
|
||||||
ecdsa_data_free(ecdsa_data);
|
|
||||||
ecdsa_data = (ECDSA_DATA *)data;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
ecdsa_data = (ECDSA_DATA *)data;
|
|
||||||
|
|
||||||
return ecdsa_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ECDSA_size(const EC_KEY *r)
|
|
||||||
{
|
|
||||||
int ret, i;
|
|
||||||
ASN1_INTEGER bs;
|
|
||||||
BIGNUM *order = NULL;
|
|
||||||
unsigned char buf[4];
|
|
||||||
const EC_GROUP *group;
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
return 0;
|
|
||||||
group = EC_KEY_get0_group(r);
|
|
||||||
if (group == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((order = BN_new()) == NULL)
|
|
||||||
return 0;
|
|
||||||
if (!EC_GROUP_get_order(group, order, NULL)) {
|
|
||||||
BN_clear_free(order);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
i = BN_num_bits(order);
|
|
||||||
bs.length = (i + 7) / 8;
|
|
||||||
bs.data = buf;
|
|
||||||
bs.type = V_ASN1_INTEGER;
|
|
||||||
/* If the top bit is set the asn1 encoding is 1 larger. */
|
|
||||||
buf[0] = 0xff;
|
|
||||||
|
|
||||||
i = i2d_ASN1_INTEGER(&bs, NULL);
|
|
||||||
i += i; /* r and s */
|
|
||||||
ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE);
|
|
||||||
BN_clear_free(order);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *ecdsa;
|
|
||||||
ecdsa = ecdsa_check(d);
|
|
||||||
if (ecdsa == NULL)
|
|
||||||
return 0;
|
|
||||||
return (CRYPTO_set_ex_data(&ecdsa->ex_data, idx, arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ECDSA_get_ex_data(EC_KEY *d, int idx)
|
|
||||||
{
|
|
||||||
ECDSA_DATA *ecdsa;
|
|
||||||
ecdsa = ecdsa_check(d);
|
|
||||||
if (ecdsa == NULL)
|
|
||||||
return NULL;
|
|
||||||
return (CRYPTO_get_ex_data(&ecdsa->ex_data, idx));
|
|
||||||
}
|
|
||||||
|
|
||||||
ECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_meth)
|
|
||||||
{
|
|
||||||
ECDSA_METHOD *ret;
|
|
||||||
|
|
||||||
ret = OPENSSL_zalloc(sizeof(*ret));
|
|
||||||
if (ret == NULL) {
|
|
||||||
ECDSAerr(ECDSA_F_ECDSA_METHOD_NEW, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ecdsa_meth)
|
|
||||||
*ret = *ecdsa_meth;
|
|
||||||
ret->flags |= ECDSA_METHOD_FLAG_ALLOCATED;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_set_sign(ECDSA_METHOD *ecdsa_method,
|
|
||||||
ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char
|
|
||||||
*dgst, int dgst_len,
|
|
||||||
const BIGNUM *inv,
|
|
||||||
const BIGNUM *rp,
|
|
||||||
EC_KEY *eckey))
|
|
||||||
{
|
|
||||||
ecdsa_method->ecdsa_do_sign = ecdsa_do_sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_set_sign_setup(ECDSA_METHOD *ecdsa_method,
|
|
||||||
int (*ecdsa_sign_setup) (EC_KEY *eckey,
|
|
||||||
BN_CTX *ctx,
|
|
||||||
BIGNUM **kinv,
|
|
||||||
BIGNUM **r))
|
|
||||||
{
|
|
||||||
ecdsa_method->ecdsa_sign_setup = ecdsa_sign_setup;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_set_verify(ECDSA_METHOD *ecdsa_method,
|
|
||||||
int (*ecdsa_do_verify) (const unsigned char
|
|
||||||
*dgst, int dgst_len,
|
|
||||||
const ECDSA_SIG *sig,
|
|
||||||
EC_KEY *eckey))
|
|
||||||
{
|
|
||||||
ecdsa_method->ecdsa_do_verify = ecdsa_do_verify;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags)
|
|
||||||
{
|
|
||||||
ecdsa_method->flags = flags | ECDSA_METHOD_FLAG_ALLOCATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name)
|
|
||||||
{
|
|
||||||
ecdsa_method->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_free(ECDSA_METHOD *ecdsa_method)
|
|
||||||
{
|
|
||||||
if (!ecdsa_method)
|
|
||||||
return;
|
|
||||||
if (ecdsa_method->flags & ECDSA_METHOD_FLAG_ALLOCATED)
|
|
||||||
OPENSSL_free(ecdsa_method);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECDSA_METHOD_set_app_data(ECDSA_METHOD *ecdsa_method, void *app)
|
|
||||||
{
|
|
||||||
ecdsa_method->app_data = app;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ECDSA_METHOD_get_app_data(ECDSA_METHOD *ecdsa_method)
|
|
||||||
{
|
|
||||||
return ecdsa_method->app_data;
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
/* crypto/ecdsa/ecs_locl.h */
|
|
||||||
/*
|
|
||||||
* Written by Nils Larsch for the OpenSSL project
|
|
||||||
*/
|
|
||||||
/* ====================================================================
|
|
||||||
* Copyright (c) 2000-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
|
|
||||||
* licensing@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).
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HEADER_ECS_LOCL_H
|
|
||||||
# define HEADER_ECS_LOCL_H
|
|
||||||
|
|
||||||
# include <openssl/ecdsa.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ecdsa_method {
|
|
||||||
const char *name;
|
|
||||||
ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char *dgst, int dgst_len,
|
|
||||||
const BIGNUM *inv, const BIGNUM *rp,
|
|
||||||
EC_KEY *eckey);
|
|
||||||
int (*ecdsa_sign_setup) (EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
|
|
||||||
BIGNUM **r);
|
|
||||||
int (*ecdsa_do_verify) (const unsigned char *dgst, int dgst_len,
|
|
||||||
const ECDSA_SIG *sig, EC_KEY *eckey);
|
|
||||||
int flags;
|
|
||||||
void *app_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The ECDSA_METHOD was allocated and can be freed */
|
|
||||||
|
|
||||||
# define ECDSA_METHOD_FLAG_ALLOCATED 0x2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this flag is set the ECDSA method is FIPS compliant and can be used in
|
|
||||||
* FIPS mode. This is set in the validated module method. If an application
|
|
||||||
* sets this flag in its own methods it is its responsibility to ensure the
|
|
||||||
* result is compliant.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define ECDSA_FLAG_FIPS_METHOD 0x1
|
|
||||||
|
|
||||||
typedef struct ecdsa_data_st {
|
|
||||||
/* EC_KEY_METH_DATA part */
|
|
||||||
int (*init) (EC_KEY *);
|
|
||||||
/* method (ECDSA) specific part */
|
|
||||||
ENGINE *engine;
|
|
||||||
int flags;
|
|
||||||
const ECDSA_METHOD *meth;
|
|
||||||
CRYPTO_EX_DATA ex_data;
|
|
||||||
} ECDSA_DATA;
|
|
||||||
|
|
||||||
/** ecdsa_check
|
|
||||||
* checks whether ECKEY->meth_data is a pointer to a ECDSA_DATA structure
|
|
||||||
* and if not it removes the old meth_data and creates a ECDSA_DATA structure.
|
|
||||||
* \param eckey pointer to a EC_KEY object
|
|
||||||
* \return pointer to a ECDSA_DATA structure
|
|
||||||
*/
|
|
||||||
ECDSA_DATA *ecdsa_check(EC_KEY *eckey);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HEADER_ECS_LOCL_H */
|
|
Loading…
x
Reference in New Issue
Block a user