ECDSA_SIG: add simple getters for commonly used struct members
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6290)
Dr. Matthias St. Pierre
5 years ago
1182 | 1182 | *ps = sig->s; |
1183 | 1183 | } |
1184 | 1184 | |
1185 | const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig) | |
1186 | { | |
1187 | return sig->r; | |
1188 | } | |
1189 | ||
1190 | const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig) | |
1191 | { | |
1192 | return sig->s; | |
1193 | } | |
1194 | ||
1185 | 1195 | int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) |
1186 | 1196 | { |
1187 | 1197 | if (r == NULL || s == NULL) |
1 | 1 | |
2 | 2 | =head1 NAME |
3 | 3 | |
4 | ECDSA_SIG_get0, ECDSA_SIG_set0, | |
4 | ECDSA_SIG_get0, ECDSA_SIG_get0_r, ECDSA_SIG_get0_s, ECDSA_SIG_set0, | |
5 | 5 | ECDSA_SIG_new, ECDSA_SIG_free, i2d_ECDSA_SIG, d2i_ECDSA_SIG, ECDSA_size, |
6 | 6 | ECDSA_sign, ECDSA_do_sign, ECDSA_verify, ECDSA_do_verify, ECDSA_sign_setup, |
7 | 7 | ECDSA_sign_ex, ECDSA_do_sign_ex - low level elliptic curve digital signature |
14 | 14 | ECDSA_SIG *ECDSA_SIG_new(void); |
15 | 15 | void ECDSA_SIG_free(ECDSA_SIG *sig); |
16 | 16 | void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); |
17 | const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); | |
18 | const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); | |
17 | 19 | int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); |
18 | 20 | int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); |
19 | 21 | ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); |
52 | 54 | ECDSA_SIG_free() frees the B<ECDSA_SIG> structure B<sig>. |
53 | 55 | |
54 | 56 | ECDSA_SIG_get0() returns internal pointers the B<r> and B<s> values contained |
55 | in B<sig>. | |
57 | in B<sig> and stores them in B<*pr> and B<*ps>, respectively. | |
58 | The pointer B<pr> or B<ps> can be NULL, in which case the corresponding value | |
59 | is not returned. | |
60 | ||
61 | The values B<r>, B<s> can also be retrieved separately by the corresponding | |
62 | function ECDSA_SIG_get0_r() and ECDSA_SIG_get0_s(), respectively. | |
56 | 63 | |
57 | 64 | The B<r> and B<s> values can be set by calling ECDSA_SIG_set0() and passing the |
58 | 65 | new values for B<r> and B<s> as parameters to the function. Calling this |
115 | 122 | |
116 | 123 | ECDSA_SIG_set0() returns 1 on success or 0 on failure. |
117 | 124 | |
125 | ECDSA_SIG_get0_r() and ECDSA_SIG_get0_s() return the corresponding value, | |
126 | or NULL if it is unset. | |
127 | ||
118 | 128 | ECDSA_size() returns the maximum length signature or 0 on error. |
119 | 129 | |
120 | 130 | ECDSA_sign(), ECDSA_sign_ex() and ECDSA_sign_setup() return 1 if successful |
1059 | 1059 | ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); |
1060 | 1060 | |
1061 | 1061 | /** Accessor for r and s fields of ECDSA_SIG |
1062 | * \param sig pointer to ECDSA_SIG pointer | |
1062 | * \param sig pointer to ECDSA_SIG structure | |
1063 | 1063 | * \param pr pointer to BIGNUM pointer for r (may be NULL) |
1064 | 1064 | * \param ps pointer to BIGNUM pointer for s (may be NULL) |
1065 | 1065 | */ |
1066 | 1066 | void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); |
1067 | 1067 | |
1068 | /** Accessor for r field of ECDSA_SIG | |
1069 | * \param sig pointer to ECDSA_SIG structure | |
1070 | */ | |
1071 | const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); | |
1072 | ||
1073 | /** Accessor for s field of ECDSA_SIG | |
1074 | * \param sig pointer to ECDSA_SIG structure | |
1075 | */ | |
1076 | const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); | |
1077 | ||
1068 | 1078 | /** Setter for r and s fields of ECDSA_SIG |
1069 | * \param sig pointer to ECDSA_SIG pointer | |
1070 | * \param r pointer to BIGNUM for r (may be NULL) | |
1071 | * \param s pointer to BIGNUM for s (may be NULL) | |
1079 | * \param sig pointer to ECDSA_SIG structure | |
1072 | 1080 | */ |
1073 | 1081 | int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); |
1074 | 1082 |