Mercurial > dropbear
comparison dsa_import.c @ 0:d7da3b1e1540 libtomcrypt
put back the 0.95 makefile which was inadvertently merged over
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 31 May 2004 18:21:40 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d7da3b1e1540 |
---|---|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
2 * | |
3 * LibTomCrypt is a library that provides various cryptographic | |
4 * algorithms in a highly modular and flexible manner. | |
5 * | |
6 * The library is free for all purposes without any express | |
7 * guarantee it works. | |
8 * | |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | |
10 */ | |
11 #include "mycrypt.h" | |
12 | |
13 #ifdef MDSA | |
14 | |
15 int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key) | |
16 { | |
17 unsigned long x, y; | |
18 int err; | |
19 | |
20 _ARGCHK(in != NULL); | |
21 _ARGCHK(key != NULL); | |
22 | |
23 /* check length */ | |
24 if ((1+2+PACKET_SIZE) > inlen) { | |
25 return CRYPT_INVALID_PACKET; | |
26 } | |
27 | |
28 /* check type */ | |
29 if ((err = packet_valid_header((unsigned char *)in, PACKET_SECT_DSA, PACKET_SUB_KEY)) != CRYPT_OK) { | |
30 return err; | |
31 } | |
32 y = PACKET_SIZE; | |
33 | |
34 /* init key */ | |
35 if (mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL) != MP_OKAY) { | |
36 return CRYPT_MEM; | |
37 } | |
38 | |
39 /* read type/qord */ | |
40 key->type = in[y++]; | |
41 key->qord = ((unsigned)in[y]<<8)|((unsigned)in[y+1]); | |
42 y += 2; | |
43 | |
44 /* input publics */ | |
45 INPUT_BIGNUM(&key->g,in,x,y, inlen); | |
46 INPUT_BIGNUM(&key->p,in,x,y, inlen); | |
47 INPUT_BIGNUM(&key->q,in,x,y, inlen); | |
48 INPUT_BIGNUM(&key->y,in,x,y, inlen); | |
49 if (key->type == PK_PRIVATE) { | |
50 INPUT_BIGNUM(&key->x,in,x,y, inlen); | |
51 } | |
52 | |
53 return CRYPT_OK; | |
54 error: | |
55 mp_clear_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL); | |
56 return err; | |
57 } | |
58 | |
59 #endif |