static void write_dsa(unsigned char **out, DSA *dsa, int ispub) { int nbyte; nbyte = BN_num_bytes(dsa->p); write_lebn(out, dsa->p, nbyte); write_lebn(out, dsa->q, 20); write_lebn(out, dsa->g, nbyte); if (ispub) write_lebn(out, dsa->pub_key, nbyte); else write_lebn(out, dsa->priv_key, 20); /* Set "invalid" for seed structure values */ memset(*out, 0xff, 24); *out += 24; return; }
static void write_dsa(unsigned char **out, DSA *dsa, int ispub) { int nbyte; BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub_key = NULL, *priv_key = NULL; DSA_get0_pqg(dsa, &p, &q, &g); DSA_get0_key(dsa, &pub_key, &priv_key); nbyte = BN_num_bytes(p); write_lebn(out, p, nbyte); write_lebn(out, q, 20); write_lebn(out, g, nbyte); if (ispub) write_lebn(out, pub_key, nbyte); else write_lebn(out, priv_key, 20); /* Set "invalid" for seed structure values */ memset(*out, 0xff, 24); *out += 24; return; }
static void write_rsa(unsigned char **out, RSA *rsa, int ispub) { int nbyte, hnbyte; nbyte = BN_num_bytes(rsa->n); hnbyte = (BN_num_bits(rsa->n) + 15) >> 4; write_lebn(out, rsa->e, 4); write_lebn(out, rsa->n, -1); if (ispub) return; write_lebn(out, rsa->p, hnbyte); write_lebn(out, rsa->q, hnbyte); write_lebn(out, rsa->dmp1, hnbyte); write_lebn(out, rsa->dmq1, hnbyte); write_lebn(out, rsa->iqmp, hnbyte); write_lebn(out, rsa->d, nbyte); }
static void write_rsa(unsigned char **out, RSA *rsa, int ispub) { int nbyte, hnbyte; BIGNUM *n, *d, *e, *p, *q, *iqmp, *dmp1, *dmq1; nbyte = RSA_size(rsa); hnbyte = (RSA_bits(rsa) + 15) >> 4; RSA_get0_key(rsa, &e, &n, &d); write_lebn(out, e, 4); write_lebn(out, n, -1); if (ispub) return; RSA_get0_factors(rsa, &p, &q); RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); write_lebn(out, p, hnbyte); write_lebn(out, q, hnbyte); write_lebn(out, dmp1, hnbyte); write_lebn(out, dmq1, hnbyte); write_lebn(out, iqmp, hnbyte); write_lebn(out, d, nbyte); }