diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1998-11-15 01:04:39 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1998-11-15 01:04:39 +0000 |
commit | 4f537f45f1df027b33455f40ed07984657df7c05 (patch) | |
tree | eef11d08cb8b1881083c30cb64a1694c7d8114bc /sbin/isakmpd | |
parent | 4cf5051aca0512c83b8d6bcaa0f6a53e639ac54c (diff) |
Not clear if we want this
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/regress/asn/Makefile | 16 | ||||
-rw-r--r-- | sbin/isakmpd/regress/asn/asntest.c | 147 | ||||
-rw-r--r-- | sbin/isakmpd/regress/asn/ssh-test-ca.pem | 12 | ||||
-rw-r--r-- | sbin/isakmpd/regress/pkcs/Makefile | 15 | ||||
-rw-r--r-- | sbin/isakmpd/regress/pkcs/pkcstest.c | 124 | ||||
-rw-r--r-- | sbin/isakmpd/regress/rsakeygen/Makefile | 14 | ||||
-rw-r--r-- | sbin/isakmpd/regress/rsakeygen/rsakeygen.c | 121 | ||||
-rw-r--r-- | sbin/isakmpd/regress/x509/Makefile | 16 | ||||
-rw-r--r-- | sbin/isakmpd/regress/x509/certificate.txt | 8 | ||||
-rw-r--r-- | sbin/isakmpd/regress/x509/x509test.c | 165 |
10 files changed, 0 insertions, 638 deletions
diff --git a/sbin/isakmpd/regress/asn/Makefile b/sbin/isakmpd/regress/asn/Makefile deleted file mode 100644 index 8975d438db7..00000000000 --- a/sbin/isakmpd/regress/asn/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 1998/11/15 00:44:06 niklas Exp $ - -# Test ASN - -PROG= asntest -SRCS= asntest.c conf.c asn.c asn_useful.c gmp_util.c log.c pkcs.c \ - sysdep.c hash.c x509.c -TOPOBJ!= cd ${.CURDIR}/../..; printf "all:\n\t@pwd\n" |${MAKE} -f- -.PATH: ${.CURDIR}/../.. ${TOPOBJ} -LDADD+= -lgmp -DPADD+= ${LIBDES} -NOMAN= -CFLAGS+= -I${.CURDIR}/../.. -I${TOPOBJ} -Wall -DEBUG= -g - -.include <bsd.prog.mk> diff --git a/sbin/isakmpd/regress/asn/asntest.c b/sbin/isakmpd/regress/asn/asntest.c deleted file mode 100644 index 1c004234f27..00000000000 --- a/sbin/isakmpd/regress/asn/asntest.c +++ /dev/null @@ -1,147 +0,0 @@ -/* $OpenBSD: asntest.c,v 1.2 1998/11/15 00:44:06 niklas Exp $ */ - -/* - * Copyright (c) 1998 Niels Provos. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ericsson Radio Systems. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This code was written under funding by Ericsson Radio Systems. - */ - -#include <sys/param.h> -#include <stdio.h> -#include <string.h> -#include <gmp.h> - -#include "conf.h" -#include "asn.h" -#include "asn_useful.h" -#include "pkcs.h" -#include "x509.h" - -int -main (void) -{ - char buf[1000]; - char buf2[1000]; - u_int32_t len; - struct norm_type test = SEQ("test", Signed); - struct norm_type test2 = SEQ("cert", Certificate); - struct norm_type *tmp, *tmp2; - struct rsa_public_key key; - struct x509_certificate cert; - int i, j; - u_int8_t *asn; - char *p; - - FILE *f = fopen ("ssh-test-ca.pem", "r"); - len = 0; - while (conf_get_line (f, buf + len, sizeof (buf) - len)) - if (buf[len] != '-') - len = strlen (buf); - - conf_decode_base64 (buf, &len, buf); - - asn_template_clone (&test, 1); - - asn_decode_sequence (buf, len, &test); - - p = ASN_SIGNED_ALGORITHM(&test); - - printf ("ObjectId: %s = %s\n", p, asn_parse_objectid (asn_ids, p)); - - asn_template_clone (&test2, 1); - - len = asn_get_len (ASN_SIGNED_DATA(&test)); - asn_decode_sequence (ASN_SIGNED_DATA(&test), len, &test2); - - tmp = asn_decompose ("cert.version", &test2); - printf ("Version: "); mpz_out_str (stdout, 16, tmp->data); - tmp = asn_decompose ("cert.serialNumber", &test2); - printf ("\nSerialNumber: "); mpz_out_str (stdout, 16, tmp->data); - tmp = asn_decompose ("cert.signature.algorithm", &test2); - printf ("\nsignature: %s\n", - asn_parse_objectid (asn_ids, (char *)tmp->data)); - - tmp = ASN_CERT_VALIDITY(&test2); - printf ("Begin: %s, End: %s\n", ASN_VAL_BEGIN(tmp), ASN_VAL_END(tmp)); - - i = 0; - while (1) - { - sprintf (buf2, "cert.issuer.RelativeDistinguishedName[%d]", i++); - tmp = asn_decompose (buf2, &test2); - if (tmp == NULL) - break; - - j = 0; - while (1) - { - sprintf (buf2, "RelativeDistinguishedName.AttributeValueAssertion[%d].AttributeType", j); - tmp2 = asn_decompose (buf2, tmp); - if (tmp2 == NULL) - break; - - printf ("Issuer: (%s) ", - asn_parse_objectid (asn_ids, tmp2->data)); - sprintf (buf2, "RelativeDistinguishedName.AttributeValueAssertion[%d].AttributeValue", j++); - tmp2 = asn_decompose (buf2, tmp); - printf ("%s\n", (char *)tmp2->data); - } - }; - - tmp = asn_decompose ("cert.subjectPublicKeyInfo.algorithm.algorithm", &test2); - printf ("Key: %s\n", asn_parse_objectid (asn_ids, tmp->data)); - - tmp = asn_decompose ("cert.subjectPublicKeyInfo.subjectPublicKey", &test2); - asn = tmp->data + 1; - - pkcs_public_key_from_asn (&key, asn, asn_get_len (asn)); - printf ("n (%u): 0x", (unsigned int)mpz_sizeinbase (key.n, 2)); - mpz_out_str (stdout, 16, key.n); - printf ("\ne: 0x"); mpz_out_str (stdout, 16, key.e); - printf ("\n"); - - printf ("Validate SIGNED: "); - if (!x509_validate_signed (buf, asn_get_len (buf), &key, &asn, &len)) - printf ("FAILED "); - else - printf ("OKAY "); - printf ("\n"); - - memset (&cert, 0, sizeof (cert)); - x509_decode_certificate (buf, asn_get_len (buf), &cert); - - printf ("Encoding Certificiate: "); - if (!x509_encode_certificate(&cert, &asn, &len)) - printf ("FAILED "); - else - printf ("OKAY "); - printf ("\n"); - return 1; -} diff --git a/sbin/isakmpd/regress/asn/ssh-test-ca.pem b/sbin/isakmpd/regress/asn/ssh-test-ca.pem deleted file mode 100644 index 4721db3bedb..00000000000 --- a/sbin/isakmpd/regress/asn/ssh-test-ca.pem +++ /dev/null @@ -1,12 +0,0 @@ ------BEGIN X509 CERTIFICATE----- -MIIB/DCCAWWgAwIBAgIDAeD0MA0GCSqGSIb3DQEBBAUAMDgxCzAJBgNVBAYTAkZJMSkwJwYDVQQ -KEyBTc2ggQ29tbXVuaWNhdGlvbnMgU2VjdXJpdHkgTHRkLjAeFw05NzEyMzEwMDAwMDBaFw05OD -EyMzEwMDAwMDBaMDgxCzAJBgNVBAYTAkZJMSkwJwYDVQQKEyBTc2ggQ29tbXVuaWNhdGlvbnMgU -2VjdXJpdHkgTHRkLjCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAmxrZfHh3PXzt4STZ27xN -v6ccHA5Zs2rJ/NmjTz+cDtJriGtfroPjPuI82H7QifrGAmG9+iHLP9bZKvs8Bur5avXTQmxg2kT -/53K74Tiox2hJEPWKNAPWKf8Y/sCXKJF0TEYtFlFCzkm+lmBmtuSDixgD5Xa1DNl3Ket7m4vOhq -8CASmjFjAUMBIGA1UdEwEB/wQIMAYBAf8CAQowDQYJKoZIhvcNAQEEBQADgYEAP66aK4rdFAT/H -PKGTEM1UQgmo8b/fi7rB90jonodOI4Xros/3R1Nj8Z5zQcx2hG5xjIAl9YpHmmPSbgtYD1SIFxF -0sWBa12FU7u/Sa8OjBvs9K0Ofnw/Sdp7on0M6f/xTVHKFCunfAbHsqFhieej6esDJBKODpbb2pJ -c6VphrlE= ------END X509 CERTIFICATE----- diff --git a/sbin/isakmpd/regress/pkcs/Makefile b/sbin/isakmpd/regress/pkcs/Makefile deleted file mode 100644 index d7f36966b7b..00000000000 --- a/sbin/isakmpd/regress/pkcs/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 1998/11/15 00:44:10 niklas Exp $ - -# Test PKCS#1 - -PROG= pkcstest -SRCS= log.c asn.c gmp_util.c pkcs.c pkcstest.c sysdep.c \ - asn_useful.c hash.c -.PATH: ${.CURDIR}/../../ -LDADD+= -lgmp -DPADD+= ${LIBDES} -NOMAN= -CFLAGS+= -I${.CURDIR}/../../ -Wall -DEBUG= -g - -.include <bsd.prog.mk> diff --git a/sbin/isakmpd/regress/pkcs/pkcstest.c b/sbin/isakmpd/regress/pkcs/pkcstest.c deleted file mode 100644 index 3d191a7d6a4..00000000000 --- a/sbin/isakmpd/regress/pkcs/pkcstest.c +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: pkcstest.c,v 1.2 1998/11/15 00:44:10 niklas Exp $ */ - -/* - * Copyright (c) 1998 Niels Provos. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ericsson Radio Systems. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This code was written under funding by Ericsson Radio Systems. - */ - -#include <sys/param.h> -#include <ctype.h> -#include <stdio.h> -#include <gmp.h> -#include <stdlib.h> -#include <string.h> - -#include "gmp_util.h" -#include "asn.h" -#include "pkcs.h" - -#define nibble2bin(y) (tolower((y)) < 'a' ? (y) - '0': tolower((y)) - 'a' + 10) -#define hexchar2bin(x) ((nibble2bin((x)[0]) << 4) + nibble2bin((x)[1])) -#define nibble2c(x) ((x) >= 10 ? ('a'-10+(x)) : ('0' + (x))) - -void asc2bin (u_int8_t *bin, u_int8_t *asc, u_int16_t len) -{ - int i; - - for (i = 0; i < len; i += 2, asc += 2) - { - *bin++ = hexchar2bin(asc); - } -} - -int -main (void) -{ - char buf[500]; - char *publickey = "304702400a66791dc6988168de7ab77419bb7fb0c001c6271027" - "0075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67cdc9a9" - "af55d655620bbab0203010001"; - char *privatekey = "3082013602010002400a66791dc6988168de7ab77419bb7fb0c001" - "c62710270075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67" - "cdc9a9af55d655620bbab020301000102400123c5b61ba36edb1d3679904199a89ea80c" - "09b9122e1400c09adcf7784676d01d23356a7d44d6bd8bd50e94bfc723fa87d8862b751" - "77691c11d757692df8881022033d48445c859e52340de704bcdda065fbb4058d740bd1d" - "67d29e9c146c11cf610220335e8408866b0fd38dc7002d3f972c67389a65d5d8306566d" - "5c4f2a5aa52628b0220045ec90071525325d3d46db79695e9afacc4523964360e02b119" - "baa366316241022015eb327360c7b60d12e5e2d16bdcd97981d17fba6b70db13b20b436" - "e24eada5902202ca6366d72781dfa24d34a9a24cbc2ae927a9958af426563ff63fb1165" - "8a461d"; - char *data = "Niels ist ein Luser!"; - u_int8_t *enc, *dec; - u_int16_t len; - u_int32_t enclen; - int erg = 0; - - struct rsa_public_key key; - struct rsa_private_key priv; - - asc2bin (buf, publickey, strlen (publickey)); - pkcs_public_key_from_asn (&key, buf, sizeof (buf)); - - printf ("n: 0x"); mpz_out_str (stdout, 16, key.n); - printf ("\ne: 0x"); mpz_out_str (stdout, 16, key.e); - printf ("\n"); - - asc2bin (buf, privatekey, strlen (privatekey)); - pkcs_private_key_from_asn (&priv, buf, sizeof (buf)); - - printf ("n: 0x"); mpz_out_str (stdout, 16, priv.n); - printf ("\ne: 0x"); mpz_out_str (stdout, 16, priv.e); - printf ("\nd: 0x"); mpz_out_str (stdout, 16, priv.d); - printf ("\np: 0x"); mpz_out_str (stdout, 16, priv.p); - printf ("\nq: 0x"); mpz_out_str (stdout, 16, priv.q); - printf ("\n"); - - printf ("Testing Signing/Verifying: "); - /* Sign with Private Key */ - if (!pkcs_rsa_encrypt (PKCS_PRIVATE, priv.n, priv.d, data, strlen(data)+1, - &enc, &enclen)) - printf ("FAILED "); - else - /* Decrypt/Verify with Public Key */ - erg = pkcs_rsa_decrypt (PKCS_PRIVATE, key.n, key.e, enc, &dec, &len); - - if (!erg || strcmp(data,dec)) - printf ("FAILED "); - else - printf ("OKAY "); - - printf ("\n"); - - pkcs_free_public_key (&key); - pkcs_free_private_key (&priv); - - return 1; -} diff --git a/sbin/isakmpd/regress/rsakeygen/Makefile b/sbin/isakmpd/regress/rsakeygen/Makefile deleted file mode 100644 index dc663ef42b8..00000000000 --- a/sbin/isakmpd/regress/rsakeygen/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 1998/11/15 00:44:11 niklas Exp $ - -# RSA Key Generation - -PROG= rsakeygen -SRCS= log.c asn.c gmp_util.c pkcs.c rsakeygen.c sysdep.c -.PATH: ${.CURDIR}/../../ -LDADD+= -lgmp -DPADD+= ${LIBDES} -NOMAN= -CFLAGS+= -I${.CURDIR}/../../ -Wall -DEBUG= -g - -.include <bsd.prog.mk> diff --git a/sbin/isakmpd/regress/rsakeygen/rsakeygen.c b/sbin/isakmpd/regress/rsakeygen/rsakeygen.c deleted file mode 100644 index 1b49fbe88be..00000000000 --- a/sbin/isakmpd/regress/rsakeygen/rsakeygen.c +++ /dev/null @@ -1,121 +0,0 @@ -/* $OpenBSD: rsakeygen.c,v 1.2 1998/11/15 00:44:11 niklas Exp $ */ - -/* - * Copyright (c) 1998 Niels Provos. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ericsson Radio Systems. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This code was written under funding by Ericsson Radio Systems. - */ - -#include <sys/param.h> -#include <ctype.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <gmp.h> - -#include "log.h" -#include "gmp_util.h" -#include "asn.h" -#include "pkcs.h" - -#define nibble2bin(y) (tolower((y)) < 'a' ? (y) - '0': tolower((y)) - 'a' + 10) -#define hexchar2bin(x) ((nibble2bin((x)[0]) << 4) + nibble2bin((x)[1])) -#define nibble2c(x) ((x) >= 10 ? ('a'-10+(x)) : ('0' + (x))) - -void asc2bin (u_int8_t *bin, u_int8_t *asc, u_int16_t len) -{ - int i; - - for (i = 0; i < len; i += 2, asc += 2) - { - *bin++ = hexchar2bin(asc); - } -} - -int -main (void) -{ - char *data = "Niels ist ein Luser!"; - u_int8_t *enc, *dec, *asn; - u_int32_t enclen; - u_int16_t len; - FILE *fd; - int erg = 0; - - struct rsa_public_key key; - struct rsa_private_key priv; - - log_debug_cmd ((enum log_classes)LOG_CRYPTO, 99); - pkcs_generate_rsa_keypair (&key, &priv, 1024); - - printf ("n: 0x"); mpz_out_str (stdout, 16, key.n); - printf ("\ne: 0x"); mpz_out_str (stdout, 16, key.e); - printf ("\n"); - - printf ("n: 0x"); mpz_out_str (stdout, 16, priv.n); - printf ("\ne: 0x"); mpz_out_str (stdout, 16, priv.e); - printf ("\nd: 0x"); mpz_out_str (stdout, 16, priv.d); - printf ("\np: 0x"); mpz_out_str (stdout, 16, priv.p); - printf ("\nq: 0x"); mpz_out_str (stdout, 16, priv.q); - printf ("\n"); - - printf ("Testing Signing/Verifying: "); - /* Sign with Private Key */ - if (!pkcs_rsa_encrypt (PKCS_PRIVATE, priv.n, priv.d, data, strlen(data)+1, - &enc, &enclen)) - printf ("FAILED "); - else - /* Decrypt/Verify with Public Key */ - erg = pkcs_rsa_decrypt (PKCS_PRIVATE, key.n, key.e, enc, &dec, &len); - - if (!erg || strcmp(data,dec)) - printf ("FAILED "); - else - printf ("OKAY "); - - printf ("\n"); - - asn = pkcs_public_key_to_asn (&key); - fd = fopen ("isakmpd_key.pub", "w"); - fwrite (asn, asn_get_len (asn), 1, fd); - fclose (fd); - free (asn); - - asn = pkcs_private_key_to_asn (&priv); - fd = fopen ("isakmpd_key", "w"); - fwrite (asn, asn_get_len (asn), 1, fd); - fclose (fd); - free (asn); - - pkcs_free_public_key (&key); - pkcs_free_private_key (&priv); - - return 1; -} diff --git a/sbin/isakmpd/regress/x509/Makefile b/sbin/isakmpd/regress/x509/Makefile deleted file mode 100644 index 6ead4d65f2c..00000000000 --- a/sbin/isakmpd/regress/x509/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 1998/11/15 00:44:11 niklas Exp $ - -# Test X509 - -PROG= x509test -SRCS= x509test.c conf.c asn.c asn_useful.c gmp_util.c log.c pkcs.c \ - sysdep.c hash.c x509.c -TOPOBJ!= cd ${.CURDIR}/../..; printf "all:\n\t@pwd\n" |${MAKE} -f- -.PATH: ${.CURDIR}/../.. ${TOPOBJ} -LDADD+= -lgmp -DPADD+= ${LIBDES} -NOMAN= -CFLAGS+= -I${.CURDIR}/../.. -I${TOPOBJ} -Wall -DEBUG= -g - -.include <bsd.prog.mk> diff --git a/sbin/isakmpd/regress/x509/certificate.txt b/sbin/isakmpd/regress/x509/certificate.txt deleted file mode 100644 index 5ebe7b81482..00000000000 --- a/sbin/isakmpd/regress/x509/certificate.txt +++ /dev/null @@ -1,8 +0,0 @@ -version: 2 -serialnumber: 0 -issuer1: SE -issuer2: We, our grandmother and God himself -subject1: SE -subject2: We, our grandmother and God himself -start: 980101000000Z -end: 990101000000Z diff --git a/sbin/isakmpd/regress/x509/x509test.c b/sbin/isakmpd/regress/x509/x509test.c deleted file mode 100644 index 7e297c7856e..00000000000 --- a/sbin/isakmpd/regress/x509/x509test.c +++ /dev/null @@ -1,165 +0,0 @@ -/* $OpenBSD: x509test.c,v 1.2 1998/11/15 00:44:12 niklas Exp $ */ - -/* - * Copyright (c) 1998 Niels Provos. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ericsson Radio Systems. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This code was written under funding by Ericsson Radio Systems. - */ - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <ctype.h> -#include <fcntl.h> -#include <stdio.h> -#include <gmp.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "conf.h" -#include "asn.h" -#include "asn_useful.h" -#include "pkcs.h" -#include "x509.h" -#include "log.h" - -u_int32_t file_sz; - -#define LINECOL(x,y) (x) = strsep (&(y), "\n\r"); \ - (x) = strchr ((x), ':') + 1; \ - while (isspace((x)[0])) (x)++; \ - - -u_int8_t * -open_file (char *name) -{ - int fd; - struct stat st; - u_int8_t *addr; - - if (stat (name, &st) == -1) - log_fatal ("stat (\"%s\", &st)", name); - file_sz = st.st_size; - fd = open (name, O_RDONLY); - if (fd == -1) - log_fatal ("open (\"%s\", O_RDONLY)", name); - addr = mmap (0, file_sz, PROT_READ | PROT_WRITE, MAP_FILE | MAP_PRIVATE, - fd, 0); - if (!addr) - log_fatal ("mmap (0, %d, PROT_READ | PROT_WRITE, MAP_FILE | MAP_PRIVATE," - "%d, 0)", file_sz, fd); - close (fd); - - return addr; -} - -int -main (void) -{ - struct rsa_private_key priv; - struct x509_certificate cert; - FILE *fd; - char *p, *p2; - u_int8_t *addr, *asn; - u_int32_t asnlen, len; - - addr = open_file ("isakmpd_key"); - if (!pkcs_private_key_from_asn (&priv, addr, asn_get_len (addr))) - { - munmap (addr, file_sz); - exit (1); - } - munmap (addr, file_sz); - - addr = open_file ("isakmpd_key.pub"); - if (!pkcs_public_key_from_asn (&cert.key, addr, asn_get_len (addr))) - { - munmap (addr, file_sz); - exit (1); - } - munmap (addr, file_sz); - - cert.signaturetype = strdup (ASN_ID_MD5WITHRSAENC); - cert.issuer1.type = strdup (ASN_ID_COUNTRY_NAME); - cert.issuer2.type = strdup (ASN_ID_ORGANIZATION_NAME); - cert.subject1.type = strdup (ASN_ID_COUNTRY_NAME); - cert.subject2.type = strdup (ASN_ID_ORGANIZATION_NAME); - - addr = open_file ("certificate.txt"); - p = addr; - - LINECOL (p2, p); cert.version = atoi (p2); - LINECOL (p2, p); cert.serialnumber = atoi (p2); - LINECOL (p2, p); cert.issuer1.val = strdup (p2); - LINECOL (p2, p); cert.issuer2.val = strdup (p2); - LINECOL (p2, p); cert.subject1.val = strdup (p2); - LINECOL (p2, p); cert.subject2.val = strdup (p2); - LINECOL (p2, p); cert.start = strdup (p2); - LINECOL (p2, p); cert.end = strdup (p2); - munmap (addr, file_sz); - - /* XXX - just put any IP number in there - XXX */ - cert.extension.type = strdup (ASN_ID_SUBJECT_ALT_NAME); - cert.extension.val = p = malloc (8); - /* XXX - this could also be encoded as norm_type, but time is lacking */ - p[0] = 0x30; p[1] = 0x06; p[2] = 0x87; p[3] = 0x04; - memset (p + 4, 0, 4); - - printf ("Encoding Certificiate: "); - if (!x509_encode_certificate(&cert, &asn, &asnlen)) - printf ("FAILED "); - else - printf ("OKAY "); - printf ("\n"); - - printf ("Creating Signature: "); - if (!x509_create_signed (asn, asnlen, &priv, &addr, &len)) - printf ("FAILED "); - else - printf ("OKAY "); - printf ("\n"); - - printf ("Validate SIGNED: "); - if (!x509_validate_signed (addr, len, &cert.key, &asn, &asnlen)) - printf ("FAILED "); - else - printf ("OKAY "); - printf ("\n"); - - fd = fopen ("cert.asn", "w"); - fwrite (addr, len, 1, fd); - fclose (fd); - - free (addr); - - return 1; -} |