diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-05-31 20:21:09 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-05-31 20:21:09 +0000 |
commit | 34b10644978bac82e1bd207ebe237d91f6ec7307 (patch) | |
tree | dd94c1a4a3e6d366976c849ba704c8fe47abc594 /sbin/isakmpd | |
parent | 34ad691e3af2f4d0d4e47e07314c5d85c0794270 (diff) |
Routines for handling KeyNote cert representation.
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/policy.c | 34 | ||||
-rw-r--r-- | sbin/isakmpd/policy.h | 6 |
2 files changed, 37 insertions, 3 deletions
diff --git a/sbin/isakmpd/policy.c b/sbin/isakmpd/policy.c index f5e0670337b..f127f549882 100644 --- a/sbin/isakmpd/policy.c +++ b/sbin/isakmpd/policy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.c,v 1.28 2001/04/09 12:34:38 ho Exp $ */ +/* $OpenBSD: policy.c,v 1.29 2001/05/31 20:21:08 angelos Exp $ */ /* $EOM: policy.c,v 1.49 2000/10/24 13:33:39 niklas Exp $ */ /* @@ -1605,12 +1605,13 @@ keynote_cert_init (void) void * keynote_cert_get (u_int8_t *data, u_int32_t len) { - char *foo = calloc (len + 1, sizeof (char)); + char *foo = malloc (len + 1); if (foo == NULL) return NULL; memcpy (foo, data, len); + foo[len] = '\0'; return foo; } @@ -1876,3 +1877,32 @@ keynote_cert_get_key (void *scert, void *keyp) LK (kn_remove_assertion, (keynote_sessid, sid)); return *(RSA **)keyp == NULL ? 0 : 1; } + +void * +keynote_cert_dup (void *cert) +{ + return strdup((char *)cert); +} + +void +keynote_serialize (void *cert, u_int8_t **data, u_int32_t *datalen) +{ + *datalen = strlen ((char *)cert) + 1; + *data = strdup (cert); /* So we allocate an extra character at the end... */ + if (*data == NULL) + log_error ("keynote_serialize: malloc (%d) failed", *datalen); +} + +/* From cert to printable */ +char * +keynote_printable (void *cert) +{ + return strdup ((char *)cert); +} + +/* From printable to cert */ +void * +keynote_from_printable (char *cert) +{ + return strdup (cert); +} diff --git a/sbin/isakmpd/policy.h b/sbin/isakmpd/policy.h index ad7ec86ee92..3cd005fee27 100644 --- a/sbin/isakmpd/policy.h +++ b/sbin/isakmpd/policy.h @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.h,v 1.7 2000/10/07 06:57:08 niklas Exp $ */ +/* $OpenBSD: policy.h,v 1.8 2001/05/31 20:21:08 angelos Exp $ */ /* $EOM: policy.h,v 1.12 2000/09/28 12:53:27 niklas Exp $ */ /* @@ -104,4 +104,8 @@ extern int keynote_cert_obtain (u_int8_t *, size_t, void *, extern int keynote_cert_get_subjects (void *, int *, u_int8_t ***, u_int32_t **); extern int keynote_cert_get_key (void *, void *); +extern void *keynote_cert_dup (void *); +extern void keynote_serialize (void *, u_int8_t **, u_int32_t *); +extern char *keynote_printable (void *); +extern void *keynote_from_printable (char *); #endif /* _POLICY_H_ */ |