2016-05-18 03:38:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2002-02-14 02:21:51 +08:00
|
|
|
*
|
2018-12-06 20:38:06 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 03:38:09 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2002-02-14 02:21:51 +08:00
|
|
|
*/
|
2002-07-26 16:41:04 +08:00
|
|
|
|
2015-10-28 03:18:59 +08:00
|
|
|
#include <openssl/ec.h>
|
2015-10-28 03:11:00 +08:00
|
|
|
#include "ec_lcl.h"
|
2015-10-28 03:18:59 +08:00
|
|
|
#include <openssl/err.h>
|
2002-02-14 02:21:51 +08:00
|
|
|
|
2005-05-16 18:11:04 +08:00
|
|
|
ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
|
|
|
|
{
|
2015-01-22 11:40:55 +08:00
|
|
|
return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey);
|
2005-05-16 18:11:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dlen,
|
2015-01-22 11:40:55 +08:00
|
|
|
const BIGNUM *kinv, const BIGNUM *rp,
|
|
|
|
EC_KEY *eckey)
|
2002-02-14 02:21:51 +08:00
|
|
|
{
|
2015-12-09 21:10:36 +08:00
|
|
|
if (eckey->meth->sign_sig != NULL)
|
2015-10-28 03:11:00 +08:00
|
|
|
return eckey->meth->sign_sig(dgst, dlen, kinv, rp, eckey);
|
2015-10-28 03:18:59 +08:00
|
|
|
ECerr(EC_F_ECDSA_DO_SIGN_EX, EC_R_OPERATION_NOT_SUPPORTED);
|
2015-10-28 03:11:00 +08:00
|
|
|
return NULL;
|
2002-02-14 02:21:51 +08:00
|
|
|
}
|
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
int ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char
|
|
|
|
*sig, unsigned int *siglen, EC_KEY *eckey)
|
2005-05-16 18:11:04 +08:00
|
|
|
{
|
2015-01-22 11:40:55 +08:00
|
|
|
return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey);
|
2005-05-16 18:11:04 +08:00
|
|
|
}
|
|
|
|
|
2015-10-29 00:57:51 +08:00
|
|
|
int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen,
|
|
|
|
unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
|
2015-01-22 11:40:55 +08:00
|
|
|
const BIGNUM *r, EC_KEY *eckey)
|
2002-02-14 02:21:51 +08:00
|
|
|
{
|
2015-12-09 21:10:36 +08:00
|
|
|
if (eckey->meth->sign != NULL)
|
2015-10-29 00:57:51 +08:00
|
|
|
return eckey->meth->sign(type, dgst, dlen, sig, siglen, kinv, r, eckey);
|
|
|
|
ECerr(EC_F_ECDSA_SIGN_EX, EC_R_OPERATION_NOT_SUPPORTED);
|
|
|
|
return 0;
|
2002-02-14 02:21:51 +08:00
|
|
|
}
|
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
|
|
|
|
BIGNUM **rp)
|
2002-02-14 02:21:51 +08:00
|
|
|
{
|
2015-12-09 21:10:36 +08:00
|
|
|
if (eckey->meth->sign_setup != NULL)
|
2015-10-28 03:11:00 +08:00
|
|
|
return eckey->meth->sign_setup(eckey, ctx_in, kinvp, rp);
|
2015-10-28 03:18:59 +08:00
|
|
|
ECerr(EC_F_ECDSA_SIGN_SETUP, EC_R_OPERATION_NOT_SUPPORTED);
|
2015-10-28 03:11:00 +08:00
|
|
|
return 0;
|
2002-02-14 02:21:51 +08:00
|
|
|
}
|