1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
15 Import DSA's p, q & g from dsaparam
17 dsaparam data: openssl dsaparam -outform DER -out dsaparam.der 2048
19 @param dsaparam The DSA param DER encoded data
20 @param dsaparamlen The length of dhparam data
21 @param key [out] the destination for the imported key
22 @return CRYPT_OK if successful.
24 int dsa_set_pqg_dsaparam(const unsigned char *dsaparam, unsigned long dsaparamlen,
29 LTC_ARGCHK(dsaparam != NULL);
30 LTC_ARGCHK(key != NULL);
31 LTC_ARGCHK(ltc_mp.name != NULL);
34 err = mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL);
35 if (err != CRYPT_OK) return err;
37 if ((err = der_decode_sequence_multi(dsaparam, dsaparamlen,
38 LTC_ASN1_INTEGER, 1UL, key->p,
39 LTC_ASN1_INTEGER, 1UL, key->q,
40 LTC_ASN1_INTEGER, 1UL, key->g,
41 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
45 key->qord = mp_unsigned_bin_size(key->q);
47 /* quick p, q, g validation, without primality testing */
48 if ((err = dsa_int_validate_pqg(key, &stat)) != CRYPT_OK) {
52 err = CRYPT_INVALID_PACKET;
65 /* ref: $Format:%D$ */
66 /* git commit: $Format:%H$ */
67 /* commit time: $Format:%ai$ */