Codebase list libcryptx-perl / b43d738
bugfixes for dsa public key import add missing prototypes to avoid warnings during build Lance Kinley 8 years ago
3 changed file(s) with 23 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
5959 elsif ($data =~ /---- BEGIN SSH2 PUBLIC KEY ----(.*?)---- END SSH2 PUBLIC KEY ----/sg) {
6060 $data = Crypt::PK::_pem_to_binary($data);
6161 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';
6363 }
6464 elsif ($data =~ /ssh-dss\s+(\S+)/) {
6565 $data = _decode_base64("$1");
6666 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';
6868 }
6969 else {
7070 return $self->_import($data);
108108 /* PKCS #1 import/export */
109109 int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key);
110110 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);
111113
112114 #endif
113115
302304 int ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key);
303305 int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key);
304306 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);
305308
306309 int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen);
307310 int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key);
331334 unsigned char *out, unsigned long *outlen,
332335 prng_state *prng, int wprng, ecc_key *key);
333336
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
334341 int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
335342 const unsigned char *hash, unsigned long hashlen,
336343 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);
337348
338349 int ecc_verify_key(ecc_key *key);
339350
455466 dsa_key *key);
456467
457468 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);
458470 int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key);
459471 int dsa_verify_key(dsa_key *key, int *stat);
460472
3333 if ((err = mp_read_radix(key->p , p , 16)) != CRYPT_OK) { goto LBL_ERR; }
3434 if ((err = mp_read_radix(key->q , q , 16)) != CRYPT_OK) { goto LBL_ERR; }
3535 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; }
3737 if (x && strlen(x) > 0) {
3838 key->type = PK_PRIVATE;
3939 }
4040 else {
4141 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;
4250 }
4351 return CRYPT_OK;
4452