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 DH key parts p and g from dhparam
17 dhparam data: openssl dhparam -outform DER -out dhparam.der 2048
19 @param dhparam The DH param DER encoded data
20 @param dhparamlen The length of dhparam data
21 @param key [out] Where the newly created DH key will be stored
22 @return CRYPT_OK if successful, note: on error all allocated memory will be freed automatically.
24 int dh_set_pg_dhparam(const unsigned char *dhparam, unsigned long dhparamlen, dh_key *key)
28 LTC_ARGCHK(key != NULL);
29 LTC_ARGCHK(ltc_mp.name != NULL);
30 LTC_ARGCHK(dhparam != NULL);
31 LTC_ARGCHK(dhparamlen > 0);
33 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
36 if ((err = der_decode_sequence_multi(dhparam, dhparamlen,
37 LTC_ASN1_INTEGER, 1UL, key->prime,
38 LTC_ASN1_INTEGER, 1UL, key->base,
39 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
52 /* ref: $Format:%D$ */
53 /* git commit: $Format:%H$ */
54 /* commit time: $Format:%ai$ */