Numerous fixups based on feedback of the DSA opacity changes.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
-/* ====================================================================
- * Copyright (c) 2016 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).
- *
+/*
+ * Licensed under the OpenSSL licenses, (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * https://www.openssl.org/source/license.html
+ * or in the file LICENSE in the source distribution.
*/
#include "dsa_locl.h"
}
}
-DSA_METHOD *DSA_meth_dup(const DSA_METHOD *meth)
+DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam)
{
DSA_METHOD *ret;
ret = OPENSSL_malloc(sizeof(DSA_METHOD));
if (ret != NULL) {
- memcpy(ret, meth, sizeof(*meth));
- ret->name = OPENSSL_strdup(meth->name);
+ memcpy(ret, dsam, sizeof(*dsam));
+ ret->name = OPENSSL_strdup(dsam->name);
}
return ret;
}
-const char *DSA_meth_get_name(const DSA_METHOD *dsam)
+const char *DSA_meth_get0_name(const DSA_METHOD *dsam)
{
return dsam->name;
}
-int DSA_meth_set_name(DSA_METHOD *dsam, const char *name)
+int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name)
{
OPENSSL_free(dsam->name);
dsam->name = OPENSSL_strdup(name);
#ifndef OPENSSL_NO_DSA
cryptodev_dsa = DSA_meth_dup(DSA_OpenSSL());
if (cryptodev_dsa != NULL) {
- DSA_meth_set_name(cryptodev_dsa, "cryptodev DSA method");
+ DSA_meth_set1_name(cryptodev_dsa, "cryptodev DSA method");
DSA_meth_set_flags(cryptodev_dsa, 0);
if (ENGINE_set_DSA(engine, cryptodev_dsa)) {
if (cryptodev_asymfeat & CRF_DSA_SIGN)
=head1 NAME
-DSA_get0_pqg, DSA_set0_pgg, DSA_get0_key, DSA_set0_key, DSA_clear_flags,
+DSA_get0_pqg, DSA_set0_pqg, DSA_get0_key, DSA_set0_key, DSA_clear_flags,
DSA_test_flags, DSA_set_flags, DSA_get0_engine - Routines for getting and
setting data in a DSA object
DSA_set_flags() sets the flags in the B<flags> parameter on the DSA object.
Multiple flags can be passed in one go (bitwise ORed together). Any flags that
are already set are left set. DSA_test_flags() tests to see whether the flags
-passed in the B<flags> parameter are currently set in the DSA object. Multple
+passed in the B<flags> parameter are currently set in the DSA object. Multiple
flags can be tested in one go. All flags that are currently set are returned, or
zero if none of the flags are set. DSA_clear_flags() clears the specified flags
within the DSA object.
=head1 SEE ALSO
-L<dsa>, L<DSA_new>, L<DSA_generate_parameters>, L<DSA_generate_key>,
-L<DSA_dup_DH>, L<DSA_do_sign>, L<DSA_set_method>, L<DSA_SIG_new>, L<DSA_sign>,
-L<DSA_size>, L<DSA_meth_new>
+L<dsa(3)>, L<DSA_new(3)>, L<DSA_generate_parameters(3)>, L<DSA_generate_key(3)>,
+L<DSA_dup_DH(3)>, L<DSA_do_sign(3)>, L<DSA_set_method(3)>, L<DSA_SIG_new(3)>,
+L<DSA_sign(3)>, L<DSA_size(3)>, L<DSA_meth_new(3)>
=head1 HISTORY
=head1 NAME
-DSA_meth_new, DSA_meth_free, DSA_meth_dup, DSA_meth_get_name, DSA_meth_set_name,
-DSA_meth_get_flags, DSA_meth_set_flags, DSA_meth_get_app_data,
-DSA_meth_set_app_data, DSA_meth_get_sign, DSA_meth_set_sign,
-DSA_meth_get_sign_setup, DSA_meth_set_sign_setup, DSA_meth_get_verify,
-DSA_meth_set_verify, DSA_meth_get_mod_exp, DSA_meth_set_mod_exp,
-DSA_meth_get_bn_mod_exp, DSA_meth_set_bn_mod_exp, DSA_meth_get_init,
-DSA_meth_set_init, DSA_meth_get_finish, DSA_meth_set_finish,
+DSA_meth_new, DSA_meth_free, DSA_meth_dup, DSA_meth_get0_name,
+DSA_meth_set1_name, DSA_meth_get_flags, DSA_meth_set_flags,
+DSA_meth_get_app_data, DSA_meth_set_app_data, DSA_meth_get_sign,
+DSA_meth_set_sign, DSA_meth_get_sign_setup, DSA_meth_set_sign_setup,
+DSA_meth_get_verify, DSA_meth_set_verify, DSA_meth_get_mod_exp,
+DSA_meth_set_mod_exp, DSA_meth_get_bn_mod_exp, DSA_meth_set_bn_mod_exp,
+DSA_meth_get_init, DSA_meth_set_init, DSA_meth_get_finish, DSA_meth_set_finish,
DSA_meth_get_paramgen, DSA_meth_set_paramgen, DSA_meth_get_keygen,
DSA_meth_set_keygen - Routines to build up DSA methods
=head1 SYNOPSIS
- #include <openssl/bio.h>
+ #include <openssl/dsa.h>
DSA_METHOD *DSA_meth_new(const char *name, int flags);
void DSA_meth_free(DSA_METHOD *dsam);
DSA_METHOD *DSA_meth_dup(const DSA_METHOD *meth);
- const char *DSA_meth_get_name(const DSA_METHOD *dsam);
- int DSA_meth_set_name(DSA_METHOD *dsam, const char *name);
+ const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
+ int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);
int DSA_meth_get_flags(DSA_METHOD *dsam);
int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
void *DSA_meth_get_app_data(const DSA_METHOD *dsam);
DSA_meth_free() destroys a B<DSA_METHOD> structure and frees up any memory
associated with it.
+DSA_meth_get0_name() will return a pointer to the name of this DSA_METHOD. This
+is a pointer to the internal name string and so should not be freed by the
+caller. DSA_meth_set1_name() sets the name of the DSA_METHOD to B<name>. The
+string is duplicated and the copy is stored in the DSA_METHOD structure, so the
+caller remains responsible for freeing the memory associated with the name.
+
DSA_meth_get_flags() returns the current value of the flags associated with this
DSA_METHOD. DSA_meth_set_flags() provides the ability to set these flags.
DSA_meth_new() and DSA_meth_dup() return the newly allocated DSA_METHOD object
or NULL on failure.
-DSA_meth_get_name() and DSA_meth_get_flags() return the name and flags
+DSA_meth_get0_name() and DSA_meth_get_flags() return the name and flags
associated with the DSA_METHOD respectively.
All other DSA_meth_get_*() functions return the appropriate function pointer
that has been set in the DSA_METHOD, or NULL if no such pointer has yet been
set.
-All DSA_meth_set_*() functions return 1 on success or 0 on failure.
+DSA_meth_set1_name() and all DSA_meth_set_*() functions return 1 on success or
+0 on failure.
=head1 SEE ALSO
-L<dsa>, L<DSA_new>, L<DSA_generate_parameters>, L<DSA_generate_key>,
-L<DSA_dup_DH>, L<DSA_do_sign>, L<DSA_set_method>, L<DSA_SIG_new>, L<DSA_sign>,
-L<DSA_size>, L<DSA_get0_p>
+L<dsa(3)>, L<DSA_new(3)>, L<DSA_generate_parameters(3)>, L<DSA_generate_key(3)>,
+L<DSA_dup_DH(3)>, L<DSA_do_sign(3)>, L<DSA_set_method(3)>, L<DSA_SIG_new3)>,
+L<DSA_sign(3)>, L<DSA_size(3)>, L<DSA_get0_pqg(3)>
=head1 HISTORY
/* Setup DSA Method */
dsa_capi_idx = DSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
ossl_dsa_meth = DSA_OpenSSL();
- DSA_meth_set_sign(capi_dsa_method, capi_dsa_do_sign);
- DSA_meth_set_verify(capi_dsa_method, DSA_meth_get_verify(ossl_dsa_meth));
- DSA_meth_set_finish(capi_dsa_method, capi_dsa_free);
- DSA_meth_set_mod_exp(capi_dsa_method, DSA_meth_get_mod_exp(ossl_dsa_meth));
- DSA_meth_set_bn_mod_exp(capi_dsa_method,
- DSA_meth_get_bn_mod_exp(ossl_dsa_meth));
+ if ( !DSA_meth_set_sign(capi_dsa_method, capi_dsa_do_sign)
+ || !DSA_meth_set_verify(capi_dsa_method,
+ DSA_meth_get_verify(ossl_dsa_meth))
+ || !DSA_meth_set_finish(capi_dsa_method, capi_dsa_free)
+ || !DSA_meth_set_mod_exp(capi_dsa_method,
+ DSA_meth_get_mod_exp(ossl_dsa_meth))
+ || !DSA_meth_set_bn_mod_exp(capi_dsa_method,
+ DSA_meth_get_bn_mod_exp(ossl_dsa_meth))) {
+ goto memerr;
+ }
}
ctx = capi_ctx_new();
DSA_METHOD *DSA_meth_new(const char *name, int flags);
void DSA_meth_free(DSA_METHOD *dsam);
-DSA_METHOD *DSA_meth_dup(const DSA_METHOD *meth);
-const char *DSA_meth_get_name(const DSA_METHOD *dsam);
-int DSA_meth_set_name(DSA_METHOD *dsam, const char *name);
+DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);
+const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
+int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);
int DSA_meth_get_flags(DSA_METHOD *dsam);
int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
void *DSA_meth_get_app_data(const DSA_METHOD *dsam);
DSA_meth_get_app_data 3963 1_1_0 EXIST::FUNCTION:DSA
DSA_meth_get_keygen 3964 1_1_0 EXIST::FUNCTION:DSA
DSA_clear_flags 3965 1_1_0 EXIST::FUNCTION:DSA
-DSA_meth_get_name 3966 1_1_0 EXIST::FUNCTION:DSA
+DSA_meth_get0_name 3966 1_1_0 EXIST::FUNCTION:DSA
DSA_meth_get_paramgen 3967 1_1_0 EXIST::FUNCTION:DSA
DSA_meth_get_sign 3968 1_1_0 EXIST::FUNCTION:DSA
DSA_meth_set_paramgen 3969 1_1_0 EXIST::FUNCTION:DSA
DSA_test_flags 3970 1_1_0 EXIST::FUNCTION:DSA
DSA_meth_set_app_data 3971 1_1_0 EXIST::FUNCTION:DSA
-DSA_meth_set_name 3972 1_1_0 EXIST::FUNCTION:DSA
+DSA_meth_set1_name 3972 1_1_0 EXIST::FUNCTION:DSA
DSA_get0_key 3973 1_1_0 EXIST::FUNCTION:DSA
DSA_meth_get_mod_exp 3974 1_1_0 EXIST::FUNCTION:DSA
DSA_set0_pqg 3975 1_1_0 EXIST::FUNCTION:DSA