+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * 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
+ */
+
/*
* Licensed under the OpenSSL licenses, (the "License");
* you may not use this file except in compliance with the License.
#include "dsa_locl.h"
#include <string.h>
+#include <openssl/err.h>
DSA_METHOD *DSA_meth_new(const char *name, int flags)
{
if (dsam != NULL) {
dsam->name = OPENSSL_strdup(name);
+ if (dsam->name == NULL) {
+ OPENSSL_free(dsam);
+ DSAerr(DSA_F_DSA_METH_NEW, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
dsam->flags = flags;
}
void DSA_meth_free(DSA_METHOD *dsam)
{
if (dsam != NULL) {
- if (dsam->name != NULL)
- OPENSSL_free(dsam->name);
+ OPENSSL_free(dsam->name);
OPENSSL_free(dsam);
}
}
if (ret != NULL) {
memcpy(ret, dsam, sizeof(*dsam));
ret->name = OPENSSL_strdup(dsam->name);
+ if (ret->name == NULL) {
+ OPENSSL_free(ret);
+ DSAerr(DSA_F_DSA_METH_DUP, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
}
return ret;
int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name)
{
+ char *tmpname;
+
+ tmpname = OPENSSL_strdup(name);
+ if (tmpname == NULL) {
+ DSAerr(DSA_F_DSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+
OPENSSL_free(dsam->name);
- dsam->name = OPENSSL_strdup(name);
+ dsam->name = tmpname;
- return dsam->name != NULL;
+ return 1;
}
int DSA_meth_get_flags(DSA_METHOD *dsam)
}
int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
- (DSA *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
- BN_CTX *, BN_MONT_CTX *)
+ (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
+ const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *)
{
return dsam->dsa_mod_exp;
}
int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
- int (*mod_exp) (DSA *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
- BIGNUM *, BN_CTX *, BN_MONT_CTX *))
+ int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
+ const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
+ BN_MONT_CTX *))
{
dsam->dsa_mod_exp = mod_exp;
return 1;
}
int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
- (DSA *, BIGNUM *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
+ (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
BN_MONT_CTX *)
{
return dsam->bn_mod_exp;
}
int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
- int (*bn_mod_exp) (DSA *, BIGNUM *, BIGNUM *, const BIGNUM *,
+ int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
const BIGNUM *, BN_CTX *, BN_MONT_CTX *))
{
dsam->bn_mod_exp = bn_mod_exp;