bugfixes for dsa public key import
add missing prototypes to avoid warnings during build
Lance Kinley
8 years ago
59 | 59 | elsif ($data =~ /---- BEGIN SSH2 PUBLIC KEY ----(.*?)---- END SSH2 PUBLIC KEY ----/sg) { |
60 | 60 | $data = Crypt::PK::_pem_to_binary($data); |
61 | 61 | my ($typ, $p, $q, $g, $y) = Crypt::PK::_ssh_parse($data); |
62 | return $self->_import_hex($p, $q, $g, undef, $y) if $typ && $p && $q && $g && $y && $typ eq 'ssh-dss'; | |
62 | return $self->_import_hex(unpack('H*',$p), unpack('H*',$q), unpack('H*',$g), undef, unpack('H*',$y)) if $typ && $p && $q && $g && $y && $typ eq 'ssh-dss'; | |
63 | 63 | } |
64 | 64 | elsif ($data =~ /ssh-dss\s+(\S+)/) { |
65 | 65 | $data = _decode_base64("$1"); |
66 | 66 | my ($typ, $p, $q, $g, $y) = Crypt::PK::_ssh_parse($data); |
67 | return $self->_import_hex($p, $q, $g, undef, $y) if $typ && $p && $q && $g && $y && $typ eq 'ssh-dss'; | |
67 | return $self->_import_hex(unpack('H*',$p), unpack('H*',$q), unpack('H*',$g), undef, unpack('H*',$y)) if $typ && $p && $q && $g && $y && $typ eq 'ssh-dss'; | |
68 | 68 | } |
69 | 69 | else { |
70 | 70 | return $self->_import($data); |
108 | 108 | /* PKCS #1 import/export */ |
109 | 109 | int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key); |
110 | 110 | int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key); |
111 | int rsa_import_pkcs8(unsigned char *in, unsigned long inlen, rsa_key *key); | |
112 | int rsa_import_hex(char *N, char *e, char *d, char *p, char *q, char *dP, char *dQ, char *qP, rsa_key *key); | |
111 | 113 | |
112 | 114 | #endif |
113 | 115 | |
302 | 304 | int ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key); |
303 | 305 | int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key); |
304 | 306 | int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, const ltc_ecc_set_type *dp); |
307 | int ecc_import_pkcs8(unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp); | |
305 | 308 | |
306 | 309 | int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen); |
307 | 310 | int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key); |
331 | 334 | unsigned char *out, unsigned long *outlen, |
332 | 335 | prng_state *prng, int wprng, ecc_key *key); |
333 | 336 | |
337 | int ecc_sign_hash_rfc7518(const unsigned char *in, unsigned long inlen, | |
338 | unsigned char *out, unsigned long *outlen, | |
339 | prng_state *prng, int wprng, ecc_key *key); | |
340 | ||
334 | 341 | int ecc_verify_hash(const unsigned char *sig, unsigned long siglen, |
335 | 342 | const unsigned char *hash, unsigned long hashlen, |
336 | 343 | int *stat, ecc_key *key); |
344 | ||
345 | int ecc_verify_hash_rfc7518(const unsigned char *sig, unsigned long siglen, | |
346 | const unsigned char *hash, unsigned long hashlen, | |
347 | int *stat, ecc_key *key); | |
337 | 348 | |
338 | 349 | int ecc_verify_key(ecc_key *key); |
339 | 350 | |
455 | 466 | dsa_key *key); |
456 | 467 | |
457 | 468 | int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key); |
469 | int dsa_import_hex(char *p, char *q, char *g, char *x, char *y, dsa_key *key); | |
458 | 470 | int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key); |
459 | 471 | int dsa_verify_key(dsa_key *key, int *stat); |
460 | 472 |
33 | 33 | if ((err = mp_read_radix(key->p , p , 16)) != CRYPT_OK) { goto LBL_ERR; } |
34 | 34 | if ((err = mp_read_radix(key->q , q , 16)) != CRYPT_OK) { goto LBL_ERR; } |
35 | 35 | if ((err = mp_read_radix(key->g , g , 16)) != CRYPT_OK) { goto LBL_ERR; } |
36 | if ((err = mp_read_radix(key->g , y , 16)) != CRYPT_OK) { goto LBL_ERR; } | |
36 | if ((err = mp_read_radix(key->y , y , 16)) != CRYPT_OK) { goto LBL_ERR; } | |
37 | 37 | if (x && strlen(x) > 0) { |
38 | 38 | key->type = PK_PRIVATE; |
39 | 39 | } |
40 | 40 | else { |
41 | 41 | key->type = PK_PUBLIC; |
42 | } | |
43 | ||
44 | key->qord = mp_unsigned_bin_size(key->q); | |
45 | ||
46 | if (key->qord >= LTC_MDSA_MAX_GROUP || key->qord <= 15 || | |
47 | (unsigned long)key->qord >= mp_unsigned_bin_size(key->p) || (mp_unsigned_bin_size(key->p) - key->qord) >= LTC_MDSA_DELTA) { | |
48 | err = CRYPT_INVALID_PACKET; | |
49 | goto LBL_ERR; | |
42 | 50 | } |
43 | 51 | return CRYPT_OK; |
44 | 52 |