syssign (p1)
public
Computes and returns the DSA signature of string, where
string is expected to be an already-computed message digest of the
original input data. The signature is issued using the private key of this
DSA instance.
Example
dsa = OpenSSL :: PKey :: DSA . new ( 2048 )
doc = " Sign me "
digest = OpenSSL :: Digest :: SHA1 . digest ( doc )
sig = dsa . syssign ( digest )
Show source static VALUE
ossl_dsa_sign(VALUE self, VALUE data)
{
DSA *dsa;
const BIGNUM *dsa_q;
unsigned int buf_len;
VALUE str;
GetDSA(self, dsa);
DSA_get0_pqg(dsa, NULL, &dsa_q, NULL);
if (!dsa_q)
ossl_raise(eDSAError, "incomplete DSA");
if (!DSA_PRIVATE(self, dsa))
ossl_raise(eDSAError, "Private DSA key needed!");
StringValue(data);
str = rb_str_new(0, DSA_size(dsa));
if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
(unsigned char *)RSTRING_PTR(str),
&buf_len, dsa)) { /* type is ignored (0) */
ossl_raise(eDSAError, NULL);
}
rb_str_set_len(str, buf_len);
return str;
}