Also follow OpenSSL by making the name non-const to avoid ugly casting.
Used by OpenSC's pkcs11-helper, as reported by Fabrice Fontaine in
https://github.com/libressl-portable/openbsd/issues/130
ok jsing sthen
-/* $OpenBSD: dsa.h,v 1.36 2022/06/27 12:28:46 tb Exp $ */
+/* $OpenBSD: dsa.h,v 1.37 2022/07/04 12:22:32 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
DSA_METHOD *DSA_meth_new(const char *name, int flags);
void DSA_meth_free(DSA_METHOD *meth);
DSA_METHOD *DSA_meth_dup(const DSA_METHOD *meth);
+#ifdef LIBRESSL_INTERNAL
+const char *DSA_meth_get0_name(const DSA_METHOD *meth);
+int DSA_meth_set1_name(DSA_METHOD *meth, const char *name);
+#endif
int DSA_meth_set_sign(DSA_METHOD *meth,
DSA_SIG *(*sign)(const unsigned char *, int, DSA *));
int DSA_meth_set_finish(DSA_METHOD *meth, int (*finish)(DSA *));
-/* $OpenBSD: dsa_locl.h,v 1.5 2022/01/14 08:29:06 tb Exp $ */
+/* $OpenBSD: dsa_locl.h,v 1.6 2022/07/04 12:22:32 tb Exp $ */
/* ====================================================================
* Copyright (c) 2007 The OpenSSL Project. All rights reserved.
*
} /* DSA_SIG */;
struct dsa_method {
- const char *name;
+ 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);
-/* $OpenBSD: dsa_meth.c,v 1.3 2022/05/07 10:31:54 tb Exp $ */
+/* $OpenBSD: dsa_meth.c,v 1.4 2022/07/04 12:22:32 tb Exp $ */
/*
* Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
*
void
DSA_meth_free(DSA_METHOD *meth)
{
- if (meth != NULL) {
- free((char *)meth->name);
- free(meth);
- }
+ if (meth == NULL)
+ return
+
+ free(meth->name);
+ free(meth);
}
DSA_METHOD *
return copy;
}
+const char *
+DSA_meth_get0_name(const DSA_METHOD *meth)
+{
+ return meth->name;
+}
+
+int
+DSA_meth_set1_name(DSA_METHOD *meth, const char *name)
+{
+ char *new_name;
+
+ if ((new_name = strdup(name)) == NULL) {
+ DSAerror(ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+
+ free(meth->name);
+ meth->name = new_name;
+
+ return 1;
+}
+
int
DSA_meth_set_sign(DSA_METHOD *meth,
DSA_SIG *(*sign)(const unsigned char *, int, DSA *))