aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2008-06-18 07:22:12 +0000
committerRob Austein <sra@hactrn.net>2008-06-18 07:22:12 +0000
commit9a60ed468a33c916bee8f89dddf1762b46c0e9d4 (patch)
treea076909434df64fd98cd56db2738ba4ac00381af /utils
parent7b96d2edf7f585079c16409f097efc68f0a161ac (diff)
cert_hash
svn path=/utils/cert_hash/Makefile; revision=1900
Diffstat (limited to 'utils')
-rw-r--r--utils/cert_hash/Makefile25
-rw-r--r--utils/cert_hash/cert_hash.c70
-rw-r--r--utils/manifest/Makefile2
3 files changed, 96 insertions, 1 deletions
diff --git a/utils/cert_hash/Makefile b/utils/cert_hash/Makefile
new file mode 100644
index 00000000..0d1e5b5a
--- /dev/null
+++ b/utils/cert_hash/Makefile
@@ -0,0 +1,25 @@
+# $Id$
+
+OPENSSL_DIR = ../../openssl/openssl
+
+CFLAGS = -g -I${OPENSSL_DIR}/include
+
+# -H -Wl,-t
+
+BIN = cert_hash
+OBJ = cert_hash.o
+LIB = ${OPENSSL_DIR}/libcrypto.a
+
+all: ${BIN}
+
+clean:
+ rm -f ${BIN} ${OBJ}
+
+${BIN}: ${OBJ} ${LIB} Makefile
+ ${CC} -g -o $@ ${OBJ} ${LIB}
+
+TARGET = ../../rpkid/testbed.dir/publication/localhost:4400/testbed/WOMBAT.cer
+
+test: all
+ ./${BIN} ${TARGET}
+ openssl dgst -sha256 -c < ${TARGET}
diff --git a/utils/cert_hash/cert_hash.c b/utils/cert_hash/cert_hash.c
new file mode 100644
index 00000000..bb498996
--- /dev/null
+++ b/utils/cert_hash/cert_hash.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2008 American Registry for Internet Numbers ("ARIN")
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $Id$ */
+
+/*
+ * Test of using BIO_f_md() filter BIO to calculate hash while reading.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#include <openssl/bio.h>
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+
+int main (int argc, char *argv[])
+{
+ BIO *b1 = NULL, *b2 = NULL;
+ X509 *x = NULL;
+ unsigned char buf[EVP_MAX_MD_SIZE];
+ unsigned i, n;
+
+ if ((b1 = BIO_new_file(argv[1], "rb")) == NULL)
+ goto done;
+
+ if ((b2 = BIO_new(BIO_f_md())) == NULL)
+ goto done;
+
+ if (!BIO_set_md(b2, EVP_sha256()))
+ goto done;
+
+ BIO_push(b2, b1);
+
+ if ((x = d2i_X509_bio(b2, NULL)) == NULL)
+ goto done;
+
+ if (X509_print_fp(stdout, x) < 0)
+ goto done;
+
+ if ((n = BIO_gets(b2, buf, sizeof(buf))) > 0) {
+ printf("\nsha26[%u]: ", n);
+ for (i = 0; i < n; i++) {
+ printf("%02x%s", buf[i], i == n - 1 ? "\n" : ":");
+ }
+ }
+
+ done:
+ if (ERR_peek_error())
+ ERR_print_errors_fp(stderr);
+
+ BIO_free_all(b2);
+
+ return 0;
+}
diff --git a/utils/manifest/Makefile b/utils/manifest/Makefile
index 1123c551..348487f8 100644
--- a/utils/manifest/Makefile
+++ b/utils/manifest/Makefile
@@ -21,5 +21,5 @@ ${BIN}: ${OBJ} ${LIB} Makefile
MANIFEST_DIR = ../../rpkid/testbed.dir/publication
test: all
- -date -u +%Y%m%d%H%M%S
+ -date -u +'now: %Y%m%d%H%M%SZ'
if test -d ${MANIFEST_DIR}; then find ${MANIFEST_DIR} -type f -name '*.mnf' -print -exec ./manifest {} \; ; else :; fi