2016-05-18 02:51:26 +08:00
|
|
|
/*
|
2021-03-11 21:27:36 +08:00
|
|
|
* Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2007-02-03 22:41:12 +08:00
|
|
|
*
|
2018-12-06 20:36:26 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:51:26 +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
|
2007-02-03 22:41:12 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <openssl/dsa.h>
|
2016-08-27 22:01:08 +08:00
|
|
|
#include "internal/refcount.h"
|
2020-01-24 12:09:33 +08:00
|
|
|
#include "internal/ffc.h"
|
2007-02-03 22:41:12 +08:00
|
|
|
|
2016-03-30 22:21:39 +08:00
|
|
|
struct dsa_st {
|
|
|
|
/*
|
|
|
|
* This first variable is used to pick up errors where a DSA is passed
|
|
|
|
* instead of of a EVP_PKEY
|
|
|
|
*/
|
|
|
|
int pad;
|
2017-04-05 19:24:14 +08:00
|
|
|
int32_t version;
|
2020-01-24 12:09:33 +08:00
|
|
|
FFC_PARAMS params;
|
2016-03-30 22:21:39 +08:00
|
|
|
BIGNUM *pub_key; /* y public key */
|
|
|
|
BIGNUM *priv_key; /* x private key */
|
|
|
|
int flags;
|
|
|
|
/* Normally used to cache montgomery values */
|
|
|
|
BN_MONT_CTX *method_mont_p;
|
2016-08-27 22:01:08 +08:00
|
|
|
CRYPTO_REF_COUNT references;
|
2020-04-14 04:34:56 +08:00
|
|
|
#ifndef FIPS_MODULE
|
2016-03-30 22:21:39 +08:00
|
|
|
CRYPTO_EX_DATA ex_data;
|
2020-01-14 09:32:42 +08:00
|
|
|
#endif
|
2016-03-30 22:21:39 +08:00
|
|
|
const DSA_METHOD *meth;
|
|
|
|
/* functional reference if 'meth' is ENGINE-provided */
|
|
|
|
ENGINE *engine;
|
|
|
|
CRYPTO_RWLOCK *lock;
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx;
|
2019-08-30 20:33:37 +08:00
|
|
|
|
|
|
|
/* Provider data */
|
|
|
|
size_t dirty_cnt; /* If any key material changes, increment this */
|
2016-03-30 22:21:39 +08:00
|
|
|
};
|
|
|
|
|
2016-06-10 05:09:48 +08:00
|
|
|
struct DSA_SIG_st {
|
|
|
|
BIGNUM *r;
|
|
|
|
BIGNUM *s;
|
|
|
|
};
|
|
|
|
|
2016-03-31 00:18:55 +08:00
|
|
|
struct dsa_method {
|
|
|
|
char *name;
|
|
|
|
DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
|
|
|
|
int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
|
|
|
|
BIGNUM **rp);
|
|
|
|
int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
|
|
|
|
DSA_SIG *sig, DSA *dsa);
|
2016-06-24 20:34:51 +08:00
|
|
|
int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1,
|
|
|
|
const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,
|
|
|
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
|
2016-03-31 00:18:55 +08:00
|
|
|
/* Can be null */
|
2016-06-24 20:34:51 +08:00
|
|
|
int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
2016-03-31 00:18:55 +08:00
|
|
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
|
|
|
int (*init) (DSA *dsa);
|
|
|
|
int (*finish) (DSA *dsa);
|
|
|
|
int flags;
|
|
|
|
void *app_data;
|
|
|
|
/* If this is non-NULL, it is used to generate DSA parameters */
|
|
|
|
int (*dsa_paramgen) (DSA *dsa, int bits,
|
|
|
|
const unsigned char *seed, int seed_len,
|
|
|
|
int *counter_ret, unsigned long *h_ret,
|
|
|
|
BN_GENCB *cb);
|
|
|
|
/* If this is non-NULL, it is used to generate DSA keys */
|
|
|
|
int (*dsa_keygen) (DSA *dsa);
|
|
|
|
};
|
|
|
|
|
Fix external symbols related to dsa keys
Partial fix for #12964
This adds ossl_ names for the following symbols:
dsa_check_pairwise, dsa_check_params, dsa_check_priv_key, dsa_check_pub_key, dsa_check_pub_key_partial,
dsa_do_sign_int, dsa_ffc_params_fromdata,
dsa_generate_ffc_parameters, dsa_generate_public_key,
dsa_get0_params, dsa_key_fromdata, dsa_new_with_ctx, dsa_pkey_method, dsa_sign_int
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14231)
2021-02-18 14:30:37 +08:00
|
|
|
DSA_SIG *ossl_dsa_do_sign_int(const unsigned char *dgst, int dlen, DSA *dsa);
|