-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
port necessary dsa functions to openssl 1.0.2
- Loading branch information
Showing
3 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// The following is a partial backport of crypto/dsa/dsa_pmeth.c, | ||
// commit cbc8a839959418d8a2c2e3ec6bdf394852c9501e on the | ||
// OpenSSL_1_1_0-stable branch. The ctrl function has been removed. | ||
|
||
#include "goopenssl.h" | ||
|
||
struct dsa_st | ||
{ | ||
int _ignored0; | ||
long _ignored1; | ||
int _ignored2; | ||
GO_BIGNUM_PTR p; | ||
GO_BIGNUM_PTR q; | ||
GO_BIGNUM_PTR g; | ||
GO_BIGNUM_PTR pub_key; | ||
GO_BIGNUM_PTR priv_key; | ||
}; | ||
|
||
|
||
void go_openssl_DSA_get0_pqg_backport(const GO_DSA_PTR dsa, | ||
GO_BIGNUM_PTR *p, GO_BIGNUM_PTR *q, GO_BIGNUM_PTR *g) | ||
{ | ||
const struct dsa_st *d = dsa; | ||
if (p != NULL) | ||
*p = d->p; | ||
if (q != NULL) | ||
*q = d->q; | ||
if (g != NULL) | ||
*g = d->g; | ||
} | ||
|
||
int go_openssl_DSA_set0_pqg_backport(GO_DSA_PTR dsa, | ||
GO_BIGNUM_PTR p, GO_BIGNUM_PTR q, GO_BIGNUM_PTR g) | ||
{ | ||
struct dsa_st *d = dsa; | ||
if ((d->p == NULL && p == NULL) | ||
|| (d->q == NULL && q == NULL) | ||
|| (d->g == NULL && g == NULL)) | ||
return 0; | ||
|
||
if (p != NULL) { | ||
go_openssl_BN_free(d->p); | ||
d->p = p; | ||
} | ||
if (q != NULL) { | ||
go_openssl_BN_free(d->q); | ||
d->q = q; | ||
} | ||
if (g != NULL) { | ||
go_openssl_BN_free(d->g); | ||
d->g = g; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
void go_openssl_DSA_get0_key_backport(const GO_DSA_PTR dsa, | ||
GO_BIGNUM_PTR *pub_key, GO_BIGNUM_PTR *priv_key) | ||
{ | ||
const struct dsa_st *d = dsa; | ||
if (pub_key != NULL) | ||
*pub_key = d->pub_key; | ||
if (priv_key != NULL) | ||
*priv_key = d->priv_key; | ||
} | ||
|
||
int go_openssl_DSA_set0_key_backport(GO_DSA_PTR dsa, GO_BIGNUM_PTR pub_key, GO_BIGNUM_PTR priv_key) | ||
{ | ||
struct dsa_st *d = dsa; | ||
if (d->pub_key == NULL && pub_key == NULL) | ||
return 0; | ||
|
||
if (pub_key != NULL) { | ||
go_openssl_BN_free(d->pub_key); | ||
d->pub_key = pub_key; | ||
} | ||
if (priv_key != NULL) { | ||
go_openssl_BN_free(d->priv_key); | ||
d->priv_key = priv_key; | ||
} | ||
|
||
return 1; | ||
} |