| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
OpenPGP data |
OpenPGP data |
| 9 |
$Id: pgpdata.c,v 1.23 2002/09/26 22:28:25 weaselp Exp $ */ |
$Id: pgpdata.c,v 1.24 2002/10/01 08:23:20 weaselp Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 974 |
return (err); |
return (err); |
| 975 |
} |
} |
| 976 |
|
|
| 977 |
int pgp_makeseckey(BUFFER *keypacket, BUFFER *outtxt, |
int pgp_makekeyheader(int type, BUFFER *keypacket, BUFFER *outtxt, |
| 978 |
BUFFER *pass, int keyalgo) |
BUFFER *pass, int keyalgo) |
| 979 |
{ |
{ |
| 980 |
BUFFER *p, *pubkey, *seckey, *subkey, *sig, *tmp, *dummy; |
BUFFER *p, *pubkey, *seckey, *subkey, *sig, *tmp, *dummy; |
| 981 |
int type, thisalgo, err = -1; |
int thisalgo, err = -1; |
| 982 |
time_t created; |
time_t created; |
| 983 |
|
|
| 984 |
|
assert(type == PGP_SECKEY || type == PGP_PUBKEY); |
| 985 |
|
|
| 986 |
p = buf_new(); |
p = buf_new(); |
| 987 |
seckey = buf_new(); |
seckey = buf_new(); |
| 988 |
pubkey = buf_new(); |
pubkey = buf_new(); |
| 992 |
dummy = buf_new(); |
dummy = buf_new(); |
| 993 |
|
|
| 994 |
buf_set(seckey, keypacket); |
buf_set(seckey, keypacket); |
| 995 |
type = pgp_getpacket(keypacket, p); |
if (type != pgp_getpacket(keypacket, p)) |
|
if (type != PGP_SECKEY) |
|
| 996 |
goto end; |
goto end; |
| 997 |
|
|
| 998 |
thisalgo = pgp_makepkpacket(PGP_SECKEY, p, outtxt, tmp, pubkey, pass, |
thisalgo = pgp_makepkpacket(type, p, outtxt, tmp, pubkey, pass, |
| 999 |
&created); |
&created); |
| 1000 |
if (thisalgo == -1 || (keyalgo != 0 && keyalgo != thisalgo)) |
if (thisalgo == -1 || (keyalgo != 0 && keyalgo != thisalgo)) |
| 1001 |
goto end; |
goto end; |
| 1002 |
|
|
| 1003 |
while ((type = pgp_getpacket(keypacket, p)) > 0) { |
while ((type = pgp_getpacket(keypacket, p)) > 0) { |
| 1004 |
if (type == PGP_SECSUBKEY) { |
if (type == PGP_SECSUBKEY || type == PGP_PUBSUBKEY) { |
| 1005 |
if (pgp_makepkpacket(PGP_SECSUBKEY, p, outtxt, dummy, subkey, pass, |
if (pgp_makepkpacket(type, p, outtxt, dummy, subkey, pass, |
| 1006 |
&created) == -1) |
&created) == -1) |
| 1007 |
goto end; |
goto end; |
| 1008 |
buf_nl(outtxt); |
buf_nl(outtxt); |