CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: christos Date: Wed Jun 14 21:43:02 UTC 2017 Modified Files: src/tests/crypto/opencrypto: h_ioctl.c Log Message: constify more to avoid gcc stupidity. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_ioctl.c diff -u src/tests/crypto/opencrypto/h_ioctl.c:1.2 src/tests/crypto/opencrypto/h_ioctl.c:1.3 --- src/tests/crypto/opencrypto/h_ioctl.c:1.2 Tue Jun 13 04:16:16 2017 +++ src/tests/crypto/opencrypto/h_ioctl.c Wed Jun 14 17:43:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: h_ioctl.c,v 1.2 2017/06/13 08:16:16 martin Exp $ */ +/* $NetBSD: h_ioctl.c,v 1.3 2017/06/14 21:43:02 christos Exp $ */ /*- * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -57,6 +57,8 @@ unsigned char aes_cipher[AES_CIPHER_LEN] { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a, }; +#define COUNT 2 + /* * CRIOGET is deprecated. */ @@ -70,10 +72,9 @@ test_ngsession(int fd) { int ret; struct crypt_sgop sg; - struct session_n_op css[2]; - const size_t cs_count = __arraycount(css); + struct session_n_op css[COUNT]; - for (size_t i = 0; i < cs_count; i++) { + for (size_t i = 0; i < COUNT; i++) { struct session_n_op *cs = &css[i]; memset(cs, 0, sizeof(*cs)); @@ -82,7 +83,7 @@ test_ngsession(int fd) cs->key = __UNCONST(&aes_key); } memset(&sg, 0, sizeof(sg)); - sg.count = cs_count; + sg.count = COUNT; sg.sessions = css; ret = ioctl(fd, CIOCNGSESSION, &sg); @@ -101,12 +102,11 @@ test_nfsession(int fd) { int ret; struct crypt_sfop sf; - u_int32_t sids[2]; - const size_t sid_count = __arraycount(sids); + u_int32_t sids[COUNT]; memset(sids, 0, sizeof(sids)); memset(&sf, 0, sizeof(sf)); - sf.count = sid_count; + sf.count = COUNT; sf.sesid = sids; ret = ioctl(fd, CIOCNFSESSION, &sf); @@ -125,10 +125,9 @@ test_ncryptm(int fd) { int ret; struct crypt_mop mop; - struct crypt_n_op css[2]; - const size_t cs_count = __arraycount(css); + struct crypt_n_op css[COUNT]; - for (size_t i = 0; i < cs_count; i++) { + for (size_t i = 0; i < COUNT; i++) { struct crypt_n_op *cs; cs = &css[i]; @@ -139,7 +138,7 @@ test_ncryptm(int fd) } memset(&mop, 0, sizeof(mop)); - mop.count = cs_count; + mop.count = COUNT; mop.reqs = css; ret = ioctl(fd, CIOCNCRYPTM, &mop); @@ -160,12 +159,10 @@ test_ncryptretm(int fd) struct session_op cs; struct crypt_mop mop; - struct crypt_n_op cnos[2]; - const size_t req_count = __arraycount(cnos); - unsigned char cno_dst[req_count][AES_CIPHER_LEN]; - + struct crypt_n_op cnos[COUNT]; + unsigned char cno_dst[COUNT][AES_CIPHER_LEN]; struct cryptret cret; - struct crypt_result crs[req_count]; + struct crypt_result crs[COUNT]; memset(&cs, 0, sizeof(cs)); cs.cipher = CRYPTO_AES_CBC; @@ -177,7 +174,7 @@ test_ncryptretm(int fd) return ret; } - for (size_t i = 0; i < req_count; i++) { + for (size_t i = 0; i < COUNT; i++) { struct crypt_n_op *cno = &cnos[i]; memset(cno, 0, sizeof(*cno)); @@ -190,13 +187,13 @@ test_ncryptretm(int fd) } memset(&mop, 0, sizeof(mop)); - mop.count = req_count; + mop.count = COUNT; mop.reqs = cnos; ret = ioctl(fd, CIOCNCRYPTM, &mop); if (ret < 0) fprintf(stderr, "failed: CIOCNCRYPTM\n"); - for (size_t i = 0; i < req_count; i++) { + for (size_t i = 0; i < COUNT; i++) { struct crypt_result *cr = &crs[i]; memset(cr, 0, sizeof(*cr)); @@ -204,7 +201,7 @@ test_ncryptretm(int fd) } memset(&cret, 0, sizeof(cret)); - cret.count = req_count; + cret.count = COUNT; cret.results = crs; ret = ioctl(fd, CIOCNCRYPTRETM, &cret); if (ret < 0)
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: martin Date: Tue Jun 13 08:16:16 UTC 2017 Modified Files: src/tests/crypto/opencrypto: h_ioctl.c Log Message: Avoid variable lenght buffers to help the stack protector (hopefully no functional change) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/crypto/opencrypto/h_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_ioctl.c diff -u src/tests/crypto/opencrypto/h_ioctl.c:1.1 src/tests/crypto/opencrypto/h_ioctl.c:1.2 --- src/tests/crypto/opencrypto/h_ioctl.c:1.1 Fri Jun 9 06:09:02 2017 +++ src/tests/crypto/opencrypto/h_ioctl.c Tue Jun 13 08:16:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: h_ioctl.c,v 1.1 2017/06/09 06:09:02 knakahara Exp $ */ +/* $NetBSD: h_ioctl.c,v 1.2 2017/06/13 08:16:16 martin Exp $ */ /*- * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -69,11 +69,11 @@ static int test_ngsession(int fd) { int ret; - int cs_count = 2; struct crypt_sgop sg; - struct session_n_op css[cs_count]; + struct session_n_op css[2]; + const size_t cs_count = __arraycount(css); - for (int i = 0; i < cs_count; i++) { + for (size_t i = 0; i < cs_count; i++) { struct session_n_op *cs = &css[i]; memset(cs, 0, sizeof(*cs)); @@ -100,9 +100,9 @@ static int test_nfsession(int fd) { int ret; - int sid_count = 2; struct crypt_sfop sf; - u_int32_t sids[sid_count]; + u_int32_t sids[2]; + const size_t sid_count = __arraycount(sids); memset(sids, 0, sizeof(sids)); memset(&sf, 0, sizeof(sf)); @@ -124,11 +124,11 @@ static int test_ncryptm(int fd) { int ret; - int cs_count = 2; struct crypt_mop mop; - struct crypt_n_op css[cs_count]; + struct crypt_n_op css[2]; + const size_t cs_count = __arraycount(css); - for (int i = 0; i < cs_count; i++) { + for (size_t i = 0; i < cs_count; i++) { struct crypt_n_op *cs; cs = &css[i]; @@ -157,11 +157,11 @@ static int test_ncryptretm(int fd) { int ret; - int req_count = 2; struct session_op cs; struct crypt_mop mop; - struct crypt_n_op cnos[req_count]; + struct crypt_n_op cnos[2]; + const size_t req_count = __arraycount(cnos); unsigned char cno_dst[req_count][AES_CIPHER_LEN]; struct cryptret cret; @@ -177,7 +177,7 @@ test_ncryptretm(int fd) return ret; } - for (int i = 0; i < req_count; i++) { + for (size_t i = 0; i < req_count; i++) { struct crypt_n_op *cno = &cnos[i]; memset(cno, 0, sizeof(*cno)); @@ -196,7 +196,7 @@ test_ncryptretm(int fd) if (ret < 0) fprintf(stderr, "failed: CIOCNCRYPTM\n"); - for (int i = 0; i < req_count; i++) { + for (size_t i = 0; i < req_count; i++) { struct crypt_result *cr = &crs[i]; memset(cr, 0, sizeof(*cr));
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: knakahara Date: Mon Apr 17 03:59:37 UTC 2017 Modified Files: src/tests/crypto/opencrypto: Makefile t_opencrypto.sh Added Files: src/tests/crypto/opencrypto: h_aescbc.c h_cbc3des.c Log Message: add opencrypto atf for CRYPTO_3DES_CBC and CRYPTO_AES_CBC(=CRYPTO_RIJNDAEL128_CBC). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/Makefile cvs rdiff -u -r0 -r1.1 src/tests/crypto/opencrypto/h_aescbc.c \ src/tests/crypto/opencrypto/h_cbc3des.c cvs rdiff -u -r1.6 -r1.7 src/tests/crypto/opencrypto/t_opencrypto.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/Makefile diff -u src/tests/crypto/opencrypto/Makefile:1.2 src/tests/crypto/opencrypto/Makefile:1.3 --- src/tests/crypto/opencrypto/Makefile:1.2 Fri Jan 17 22:33:02 2014 +++ src/tests/crypto/opencrypto/Makefile Mon Apr 17 03:59:37 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2014/01/17 22:33:02 pgoyette Exp $ +# $NetBSD: Makefile,v 1.3 2017/04/17 03:59:37 knakahara Exp $ .include @@ -9,11 +9,13 @@ TESTS_SH+= t_opencrypto BINDIR= ${TESTSDIR} MKMAN= no +PROGS+= h_aescbc PROGS+= h_aesctr1 PROGS+= h_aesctr2 PROGS+= h_arc4 PROGS+= h_camellia PROGS+= h_cbcdes +PROGS+= h_cbc3des PROGS+= h_comp PROGS+= h_comp_zlib PROGS+= h_comp_zlib_rnd Index: src/tests/crypto/opencrypto/t_opencrypto.sh diff -u src/tests/crypto/opencrypto/t_opencrypto.sh:1.6 src/tests/crypto/opencrypto/t_opencrypto.sh:1.7 --- src/tests/crypto/opencrypto/t_opencrypto.sh:1.6 Sat Dec 26 07:10:03 2015 +++ src/tests/crypto/opencrypto/t_opencrypto.sh Mon Apr 17 03:59:37 2017 @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.6 2015/12/26 07:10:03 pgoyette Exp $ +# $NetBSD: t_opencrypto.sh,v 1.7 2017/04/17 03:59:37 knakahara Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -113,6 +113,19 @@ cbcdes_cleanup() { common_cleanup } +atf_test_case cbc3des cleanup +cbc3des_head() { + common_head "Test 3DES_CBC crypto" +} + +cbc3des_body() { + common_body h_cbc3des +} + +cbc3des_cleanup() { + common_cleanup +} + atf_test_case comp cleanup comp_head() { common_head "Test GZIP_COMP Compression" @@ -178,6 +191,19 @@ aesctr2_cleanup() { common_cleanup } +atf_test_case aescbc cleanup +aescbc_head() { + common_head "Test AES_CBC crypto" +} + +aescbc_body() { + common_body h_aescbc +} + +aescbc_cleanup() { + common_cleanup +} + atf_test_case gcm cleanup gcm_head() { common_head "Test AES_GCM_16 crypto" @@ -262,11 +288,13 @@ atf_init_test_cases() { atf_add_test_case arc4 atf_add_test_case camellia atf_add_test_case cbcdes + atf_add_test_case cbc3des atf_add_test_case comp atf_add_test_case comp_deflate atf_add_test_case comp_zlib_rnd atf_add_test_case aesctr1 atf_add_test_case aesctr2 + atf_add_test_case aescbc atf_add_test_case gcm atf_add_test_case md5 atf_add_test_case md5_hmac Added files: Index: src/tests/crypto/opencrypto/h_aescbc.c diff -u /dev/null src/tests/crypto/opencrypto/h_aescbc.c:1.1 --- /dev/null Mon Apr 17 03:59:37 2017 +++ src/tests/crypto/opencrypto/h_aescbc.c Mon Apr 17 03:59:37 2017 @@ -0,0 +1,163 @@ +/* $NetBSD: h_aescbc.c,v 1.1 2017/04/17 03:59:37 knakahara Exp $ */ + +/*- + * Copyright (c) 2017 Internet Initiative Japan Inc. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +/* + * Test vectors from RFC 3602 + */ + +const struct { + size_t len; + size_t key_len; + unsigned char key[16]; + unsig
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sat Dec 26 07:10:03 UTC 2015 Modified Files: src/tests/crypto/opencrypto: t_opencrypto.sh Log Message: For the skipped ARC4 test, don't bother trying to run the test clean-up code. It runs rump.halt which returns an error status (since rump was never started in the first place), and this causes atf to complain about the cleanup routine's return status, logging the test as a failure! To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/crypto/opencrypto/t_opencrypto.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/t_opencrypto.sh diff -u src/tests/crypto/opencrypto/t_opencrypto.sh:1.5 src/tests/crypto/opencrypto/t_opencrypto.sh:1.6 --- src/tests/crypto/opencrypto/t_opencrypto.sh:1.5 Mon Mar 16 16:42:27 2015 +++ src/tests/crypto/opencrypto/t_opencrypto.sh Sat Dec 26 07:10:03 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.5 2015/03/16 16:42:27 prlw1 Exp $ +# $NetBSD: t_opencrypto.sh,v 1.6 2015/12/26 07:10:03 pgoyette Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -80,7 +80,11 @@ arc4_body() { } arc4_cleanup() { - common_cleanup + # No cleanup required since test is skipped. Trying to run rump.halt + # at this point fails, causing the ATF environment to erroneously + # report a failed test! + # + # common_cleanup } atf_test_case camellia cleanup
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: prlw1 Date: Mon Mar 16 16:42:27 UTC 2015 Modified Files: src/tests/crypto/opencrypto: t_opencrypto.sh Log Message: correct test name To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/crypto/opencrypto/t_opencrypto.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/t_opencrypto.sh diff -u src/tests/crypto/opencrypto/t_opencrypto.sh:1.4 src/tests/crypto/opencrypto/t_opencrypto.sh:1.5 --- src/tests/crypto/opencrypto/t_opencrypto.sh:1.4 Sat Jan 18 15:15:16 2014 +++ src/tests/crypto/opencrypto/t_opencrypto.sh Mon Mar 16 16:42:27 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.4 2014/01/18 15:15:16 pgoyette Exp $ +# $NetBSD: t_opencrypto.sh,v 1.5 2015/03/16 16:42:27 prlw1 Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -98,7 +98,7 @@ camellia_cleanup() { atf_test_case cbcdes cleanup cbcdes_head() { - common_head "Test ARC4 crypto" + common_head "Test DES_CBC crypto" } cbcdes_body() {
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sun Jan 19 13:41:00 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_aesctr1.c Log Message: Sprinkle in some UNCONST() To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/crypto/opencrypto/h_aesctr1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_aesctr1.c diff -u src/tests/crypto/opencrypto/h_aesctr1.c:1.3 src/tests/crypto/opencrypto/h_aesctr1.c:1.4 --- src/tests/crypto/opencrypto/h_aesctr1.c:1.3 Sat Jan 18 20:40:27 2014 +++ src/tests/crypto/opencrypto/h_aesctr1.c Sun Jan 19 13:40:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_aesctr1.c,v 1.3 2014/01/18 20:40:27 pgoyette Exp $ */ +/* $NetBSD: h_aesctr1.c,v 1.4 2014/01/19 13:40:59 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -219,7 +219,7 @@ main(void) memset(&cs, 0, sizeof(cs)); cs.cipher = CRYPTO_AES_CTR; cs.keylen = tests[i].key_len; - cs.key = &tests[i].key; + cs.key = __UNCONST(&tests[i].key); res = ioctl(fd, CIOCGSESSION, &cs); if (res < 0) err(1, "CIOCGSESSION %zu", i); @@ -228,10 +228,10 @@ main(void) co.ses = cs.ses; co.op = COP_ENCRYPT; co.len = tests[i].len; - co.src = &tests[i].plaintx; + co.src = __UNCONST(&tests[i].plaintx); co.dst = buf; co.dst_len = sizeof(buf); - co.iv = &tests[i].iv; + co.iv = __UNCONST(&tests[i].iv); res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT %zu", i);
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sat Jan 18 20:40:27 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_aesctr1.c Log Message: Include more of the test cases from RFC 1321. XXX cases 3, 6, and 9 are currently disabled because we don't seem to handle plain-text in other than 8-byte chunks. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_aesctr1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_aesctr1.c diff -u src/tests/crypto/opencrypto/h_aesctr1.c:1.2 src/tests/crypto/opencrypto/h_aesctr1.c:1.3 --- src/tests/crypto/opencrypto/h_aesctr1.c:1.2 Fri Jan 17 14:16:08 2014 +++ src/tests/crypto/opencrypto/h_aesctr1.c Sat Jan 18 20:40:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_aesctr1.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ +/* $NetBSD: h_aesctr1.c,v 1.3 2014/01/18 20:40:27 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,55 +30,221 @@ #include #include #include +#include #include #include #include -unsigned char key[20] = {0xae, 0x68, 0x52, 0xf8, 0x12, 0x10, 0x67, 0xcc, - 0x4b, 0xf7, 0xa5, 0x76, 0x55, 0x77, 0xf3, 0x9e, - 0x00, 0x00, 0x00, 0x30}; -unsigned char iv[8] = {0}; -char plaintx[16] = "Single block msg"; -const unsigned char ciphertx[16] = { - 0xe4, 0x09, 0x5d, 0x4f, 0xb7, 0xa7, 0xb3, 0x79, - 0x2d, 0x61, 0x75, 0xa3, 0x26, 0x13, 0x11, 0xb8 +/* + * Test vectors from RFC 3686 + * + * Test vectors 3, 6, and 9 are disabled because we don't support + * 36-byte (ie, unpadded) operations. + */ + +const struct { + size_t len; + size_t key_len; + unsigned char key[36]; /* Includes 32-bit nonce */ + unsigned char iv[8]; + unsigned char plaintx[36]; + unsigned char ciphertx[36]; +} tests[] = { + /* Test Vector #1: Encrypting 16 octets using AES-CTR w/ 128-bit key*/ + { 16, 20, + { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, + 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E, + 0x00, 0x00, 0x00, 0x30 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, + 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8 } + }, + + /* Test Vector #2: Encrypting 32 octets using AES-CTR w/ 128-bit key */ + { 32, 20, + { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, + 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63, + 0x00, 0x6C, 0xB6, 0xDB }, + { 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, + 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, + 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, + 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28 } + }, + + /* Test Vector #3: Encrypting 36 octets using AES-CTR w/ 128-bit key */ +/* { 36, 20, + { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, + 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC, + 0x00, 0xE0, 0x01, 0x7B }, + { 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + { 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, + 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, + 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, + 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, + 0x25, 0xB2, 0x07, 0x2F } + }, +*/ + /* Test Vector #4: Encrypting 16 octets using AES-CTR w/ 192-bit key */ + { 16, 28, + { 0x16, 0xAF, 0x5B, 0x14, 0x5F, 0xC9, 0xF5, 0x79, + 0xC1, 0x75, 0xF9, 0x3E, 0x3B, 0xFB, 0x0E, 0xED, + 0x86, 0x3D, 0x06, 0xCC, 0xFD, 0xB7, 0x85, 0x15, + 0x00, 0x00, 0x00, 0x48 }, + { 0x36, 0x73, 0x3C, 0x14, 0x7D, 0x6D, 0x93, 0xCB }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0x4B, 0x55, 0x38, 0x4F, 0xE2, 0x59, 0xC9, 0xC8, + 0x4E, 0x79, 0x35, 0xA0, 0x03, 0xCB, 0xE9, 0x28 } + }, + + /* Test Vector #5: Encrypting 32 octets using AES-CTR w/ 192-bit key */ + { 32, 28, + { 0x7C, 0x5C, 0xB2, 0x40, 0x1B, 0x3D, 0xC3, 0x3C, + 0x19, 0xE7, 0x34, 0x08, 0x19, 0xE0, 0xF6, 0x9C, + 0x67, 0x8C, 0x3D, 0xB8, 0xE6, 0xF6, 0xA9, 0x1A, + 0x00, 0x96, 0xB0, 0x3B }, + { 0x02, 0x0C, 0x6E, 0xAD, 0xC2, 0xCB, 0x50, 0x0D }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D,
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sat Jan 18 20:10:34 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_md5.c Log Message: Remove some debugging code. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/crypto/opencrypto/h_md5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_md5.c diff -u src/tests/crypto/opencrypto/h_md5.c:1.4 src/tests/crypto/opencrypto/h_md5.c:1.5 --- src/tests/crypto/opencrypto/h_md5.c:1.4 Sat Jan 18 19:44:41 2014 +++ src/tests/crypto/opencrypto/h_md5.c Sat Jan 18 20:10:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_md5.c,v 1.4 2014/01/18 19:44:41 pgoyette Exp $ */ +/* $NetBSD: h_md5.c,v 1.5 2014/01/18 20:10:34 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -98,16 +98,9 @@ main(void) if (res < 0) err(1, "CIOCCRYPT test %zu", i); - if (memcmp(co.mac, tests[i].digest, - sizeof(tests[i].digest))) { - size_t j; - - printf(" Idx Actual Golden\n"); - for (j=0; j < sizeof(tests[i].digest); j++) -printf("0x%02zx: 0x%02x 0x%02x\n", -j, buf[j], tests[i].digest[j]); + if (memcmp(co.mac, tests[i].digest, sizeof(tests[i].digest))) errx(1, "verification failed test %zu", i); - } + res = ioctl(fd, CIOCFSESSION, &cs.ses); if (res < 0) err(1, "CIOCFSESSION test %zu", i);
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sat Jan 18 19:44:41 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_md5.c Log Message: Free each crypto(4) session when we're done with it. (A new session is created for each test case.) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/crypto/opencrypto/h_md5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_md5.c diff -u src/tests/crypto/opencrypto/h_md5.c:1.3 src/tests/crypto/opencrypto/h_md5.c:1.4 --- src/tests/crypto/opencrypto/h_md5.c:1.3 Sat Jan 18 15:55:32 2014 +++ src/tests/crypto/opencrypto/h_md5.c Sat Jan 18 19:44:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_md5.c,v 1.3 2014/01/18 15:55:32 pgoyette Exp $ */ +/* $NetBSD: h_md5.c,v 1.4 2014/01/18 19:44:41 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -108,6 +108,9 @@ main(void) j, buf[j], tests[i].digest[j]); errx(1, "verification failed test %zu", i); } + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %zu", i); } return 0; }
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sat Jan 18 15:55:32 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_md5.c Log Message: Fix verification to use correct buffer. Use test cases defined in RFC 1321 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_md5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_md5.c diff -u src/tests/crypto/opencrypto/h_md5.c:1.2 src/tests/crypto/opencrypto/h_md5.c:1.3 --- src/tests/crypto/opencrypto/h_md5.c:1.2 Fri Jan 17 14:16:08 2014 +++ src/tests/crypto/opencrypto/h_md5.c Sat Jan 18 15:55:32 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_md5.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ +/* $NetBSD: h_md5.c,v 1.3 2014/01/18 15:55:32 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -36,18 +36,42 @@ #include -unsigned char key[] = "abcdefgh"; -unsigned char iv[8] = {0}; -char plaintx[16] = "1234567890123456"; -const unsigned char ciphertx[16] = { - 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, - 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +/* Test vectors from RFC1321 */ + +const struct { + size_t len; + unsigned char plaintx[80]; + unsigned char digest[16]; +} tests[] = { + { 0, "", + { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, + 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, + { 1, "a", + { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, + 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, + { 3, "abc", + { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, + 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, + { 14, "message digest", + { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, + 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, + { 26, "abcdefghijklmnopqrstuvwxyz", + { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, + 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, + { 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, + 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, + { 80, "123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890", + { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, + 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, }; int main(void) { int fd, res; + size_t i; struct session_op cs; struct crypt_op co; unsigned char buf[16]; @@ -57,26 +81,33 @@ main(void) err(1, "open"); memset(&cs, 0, sizeof(cs)); cs.mac = CRYPTO_MD5; -#if 0 - cs.mackeylen = 8; - cs.mackey = key; -#endif - res = ioctl(fd, CIOCGSESSION, &cs); - if (res < 0) - err(1, "CIOCGSESSION"); - - memset(&co, 0, sizeof(co)); - co.ses = cs.ses; - co.op = COP_ENCRYPT; - co.len = sizeof(plaintx); - co.src = plaintx; - co.mac = buf; - res = ioctl(fd, CIOCCRYPT, &co); - if (res < 0) - err(1, "CIOCCRYPT"); - - if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) - errx(1, "verification failed"); + for (i = 0; i < __arraycount(tests); i++) { + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %zu", i); + + memset(&co, 0, sizeof(co)); + memset(&buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].plaintx); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %zu", i); + + if (memcmp(co.mac, tests[i].digest, + sizeof(tests[i].digest))) { + size_t j; + + printf(" Idx Actual Golden\n"); + for (j=0; j < sizeof(tests[i].digest); j++) +printf("0x%02zx: 0x%02x 0x%02x\n", +j, buf[j], tests[i].digest[j]); + errx(1, "verification failed test %zu", i); + } + } return 0; }
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Sat Jan 18 15:15:16 UTC 2014 Modified Files: src/tests/crypto/opencrypto: t_opencrypto.sh Log Message: Add the test cases for sha1_hmac To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/crypto/opencrypto/t_opencrypto.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/t_opencrypto.sh diff -u src/tests/crypto/opencrypto/t_opencrypto.sh:1.3 src/tests/crypto/opencrypto/t_opencrypto.sh:1.4 --- src/tests/crypto/opencrypto/t_opencrypto.sh:1.3 Fri Jan 17 19:35:33 2014 +++ src/tests/crypto/opencrypto/t_opencrypto.sh Sat Jan 18 15:15:16 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.3 2014/01/17 19:35:33 pgoyette Exp $ +# $NetBSD: t_opencrypto.sh,v 1.4 2014/01/18 15:15:16 pgoyette Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -226,6 +226,19 @@ null_cleanup() { common_cleanup } +atf_test_case sha1_hmac cleanup +sha1_hmac_head() { + common_head "Test SHA1_HMAC crypto" +} + +sha1_hmac_body() { + common_body h_sha1hmac +} + +sha1_hmac_cleanup() { + common_cleanup +} + atf_test_case xcbcmac cleanup xcbcmac_head() { common_head "Test XCBC_MAC_96 crypto" @@ -254,5 +267,6 @@ atf_init_test_cases() { atf_add_test_case md5 atf_add_test_case md5_hmac atf_add_test_case null + atf_add_test_case sha1_hmac atf_add_test_case xcbcmac }
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: joerg Date: Sat Jan 18 02:31:14 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_md5hmac.c h_sha1hmac.c Log Message: Needs some unconst. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/crypto/opencrypto/h_md5hmac.c cvs rdiff -u -r1.1 -r1.2 src/tests/crypto/opencrypto/h_sha1hmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_md5hmac.c diff -u src/tests/crypto/opencrypto/h_md5hmac.c:1.3 src/tests/crypto/opencrypto/h_md5hmac.c:1.4 --- src/tests/crypto/opencrypto/h_md5hmac.c:1.3 Fri Jan 17 22:31:25 2014 +++ src/tests/crypto/opencrypto/h_md5hmac.c Sat Jan 18 02:31:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_md5hmac.c,v 1.3 2014/01/17 22:31:25 pgoyette Exp $ */ +/* $NetBSD: h_md5hmac.c,v 1.4 2014/01/18 02:31:14 joerg Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -154,7 +154,7 @@ main(void) memset(&cs, 0, sizeof(cs)); cs.mac = CRYPTO_MD5_HMAC; cs.mackeylen = tests[i].key_len; - cs.mackey = &tests[i].key; + cs.mackey = __UNCONST(&tests[i].key); res = ioctl(fd, CIOCGSESSION, &cs); if (res < 0) err(1, "CIOCGSESSION test %d", tests[i].num); @@ -164,7 +164,7 @@ main(void) co.ses = cs.ses; co.op = COP_ENCRYPT; co.len = tests[i].len; - co.src = &tests[i].data; + co.src = __UNCONST(&tests[i].data); co.mac = buf; res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) Index: src/tests/crypto/opencrypto/h_sha1hmac.c diff -u src/tests/crypto/opencrypto/h_sha1hmac.c:1.1 src/tests/crypto/opencrypto/h_sha1hmac.c:1.2 --- src/tests/crypto/opencrypto/h_sha1hmac.c:1.1 Fri Jan 17 22:33:02 2014 +++ src/tests/crypto/opencrypto/h_sha1hmac.c Sat Jan 18 02:31:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_sha1hmac.c,v 1.1 2014/01/17 22:33:02 pgoyette Exp $ */ +/* $NetBSD: h_sha1hmac.c,v 1.2 2014/01/18 02:31:14 joerg Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -164,7 +164,7 @@ main(void) memset(&cs, 0, sizeof(cs)); cs.mac = CRYPTO_SHA1_HMAC; cs.mackeylen = tests[i].key_len; - cs.mackey = &tests[i].key;; + cs.mackey = __UNCONST(&tests[i].key); res = ioctl(fd, CIOCGSESSION, &cs); if (res < 0) err(1, "CIOCGSESSION test %d", tests[i].num); @@ -174,7 +174,7 @@ main(void) co.ses = cs.ses; co.op = COP_ENCRYPT; co.len = tests[i].len; - co.src = &tests[i].data; + co.src = __UNCONST(&tests[i].data); co.mac = buf; res = ioctl(fd, CIOCCRYPT, &co); if (res < 0)
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Fri Jan 17 22:33:02 UTC 2014 Modified Files: src/tests/crypto/opencrypto: Makefile Added Files: src/tests/crypto/opencrypto: h_sha1hmac.c Log Message: Additional tests for SHA1_HMAC (with test cases from RFC2202) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/crypto/opencrypto/Makefile cvs rdiff -u -r0 -r1.1 src/tests/crypto/opencrypto/h_sha1hmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/Makefile diff -u src/tests/crypto/opencrypto/Makefile:1.1 src/tests/crypto/opencrypto/Makefile:1.2 --- src/tests/crypto/opencrypto/Makefile:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/Makefile Fri Jan 17 22:33:02 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ +# $NetBSD: Makefile,v 1.2 2014/01/17 22:33:02 pgoyette Exp $ .include @@ -21,6 +21,7 @@ PROGS+= h_gcm PROGS+= h_md5 PROGS+= h_md5hmac PROGS+= h_null +PROGS+= h_sha1hmac PROGS+= h_xcbcmac LDADD.h_comp_zlib+= -lz Added files: Index: src/tests/crypto/opencrypto/h_sha1hmac.c diff -u /dev/null src/tests/crypto/opencrypto/h_sha1hmac.c:1.1 --- /dev/null Fri Jan 17 22:33:03 2014 +++ src/tests/crypto/opencrypto/h_sha1hmac.c Fri Jan 17 22:33:02 2014 @@ -0,0 +1,191 @@ +/* $NetBSD: h_sha1hmac.c,v 1.1 2014/01/17 22:33:02 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +#define SHA1_HMAC_KEYLEN 20 /* Only key-length we support */ + +/* Test data from RFC2202 */ +const struct { + int num; +size_t key_len; +size_t len; +unsigned char key[80]; +unsigned char data[80]; +unsigned char mac[20]; +} tests[] = { +/* Test #1 */ + { 1, 20, 8, + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + "Hi There", + { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, + 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, + 0xf1, 0x46, 0xbe, 0x00 } + }, +/* Test #2 */ + { 2, 4, 28, + "Jefe", + "what do ya want for nothing?", + { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, + 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, + 0x25, 0x9a, 0x7c, 0x79 } + }, +/* Test #3 */ + { 3, 20, 50, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, + 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, + 0x63, 0xf1, 0x75, 0xd3 } + }, +/* Test #4 */ + { 4, 25, 50, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19 }, + { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0x
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Fri Jan 17 22:31:25 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_md5hmac.c Log Message: Add additional test cases from RFC2202 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_md5hmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_md5hmac.c diff -u src/tests/crypto/opencrypto/h_md5hmac.c:1.2 src/tests/crypto/opencrypto/h_md5hmac.c:1.3 --- src/tests/crypto/opencrypto/h_md5hmac.c:1.2 Fri Jan 17 14:16:08 2014 +++ src/tests/crypto/opencrypto/h_md5hmac.c Fri Jan 17 22:31:25 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_md5hmac.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ +/* $NetBSD: h_md5hmac.c,v 1.3 2014/01/17 22:31:25 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -36,19 +36,109 @@ #include -unsigned char key[16] = { - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b -}; -char plaintx[8] = "Hi There"; -const unsigned char ciphertx[16] = { - 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, - 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +#define MD5_HMAC_KEYLEN 16 /* Fixed key length supported */ + +/* Test data from RFC2202 */ +const struct { + int num; +size_t key_len; +size_t len; + unsigned char key[80]; + unsigned char data[80]; +unsigned char mac[16]; +} tests[] = { + /* Test #1 */ + { 1, 16, 8, + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b }, + "Hi There", + { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, + 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d } + }, + /* Test #2 */ + { 2, 4, 28, + "Jefe", + "what do ya want for nothing?", + { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, + 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 } + }, + /* Test #3 */ + { 3, 16, 50, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, + 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } + }, + /* Test #4 */ + { 4, 25, 50, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19 }, + { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd }, + { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea, + 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 } + }, + /* Test #5 */ + { 5, 16, 20, + { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c }, + "Test With Truncation", + { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00, + 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c } + }, + /* Test #6 */ + { 6, 80, 54, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key - Hash Key First", + { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f, + 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd } + }, + /* Test #7 */ + { 7, 80, 73, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key and Larger " + "Than One Block-Size Data", + { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0x
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Fri Jan 17 19:39:51 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_camellia.c Log Message: Use RFC 3713 vector, add comment to identify the source To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_camellia.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_camellia.c diff -u src/tests/crypto/opencrypto/h_camellia.c:1.2 src/tests/crypto/opencrypto/h_camellia.c:1.3 --- src/tests/crypto/opencrypto/h_camellia.c:1.2 Fri Jan 17 14:16:08 2014 +++ src/tests/crypto/opencrypto/h_camellia.c Fri Jan 17 19:39:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_camellia.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ +/* $NetBSD: h_camellia.c,v 1.3 2014/01/17 19:39:51 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -36,6 +36,7 @@ #include +/* Test vector from RFC3713 */ unsigned char key[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, @@ -44,8 +45,8 @@ unsigned char iv[16] = {0}; char plaintx[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}; const unsigned char ciphertx[16] = { - 0xe4, 0x09, 0x5d, 0x4f, 0xb7, 0xa7, 0xb3, 0x79, - 0x2d, 0x61, 0x75, 0xa3, 0x26, 0x13, 0x11, 0xb8 + 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, + 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 }; int
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Fri Jan 17 19:35:33 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_null.c t_opencrypto.sh Log Message: Reenable h_null (NULL_CBC) test. It works if we correctly pass a NULL iv. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_null.c \ src/tests/crypto/opencrypto/t_opencrypto.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_null.c diff -u src/tests/crypto/opencrypto/h_null.c:1.2 src/tests/crypto/opencrypto/h_null.c:1.3 --- src/tests/crypto/opencrypto/h_null.c:1.2 Fri Jan 17 14:16:08 2014 +++ src/tests/crypto/opencrypto/h_null.c Fri Jan 17 19:35:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_null.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ +/* $NetBSD: h_null.c,v 1.3 2014/01/17 19:35:33 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -37,12 +37,7 @@ #include unsigned char key[] = "abcdefgh"; -unsigned char iv[8] = {0}; char plaintx[16] = "1234567890123456"; -const unsigned char ciphertx[16] = { - 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, - 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c -}; int main(void) @@ -70,12 +65,11 @@ main(void) co.src = plaintx; co.dst = buf; co.dst_len = sizeof(buf); - co.iv = iv; res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT"); - if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + if (memcmp(co.dst, plaintx, sizeof(plaintx))) errx(1, "verification failed"); return 0; Index: src/tests/crypto/opencrypto/t_opencrypto.sh diff -u src/tests/crypto/opencrypto/t_opencrypto.sh:1.2 src/tests/crypto/opencrypto/t_opencrypto.sh:1.3 --- src/tests/crypto/opencrypto/t_opencrypto.sh:1.2 Fri Jan 17 14:14:54 2014 +++ src/tests/crypto/opencrypto/t_opencrypto.sh Fri Jan 17 19:35:33 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.2 2014/01/17 14:14:54 pgoyette Exp $ +# $NetBSD: t_opencrypto.sh,v 1.3 2014/01/17 19:35:33 pgoyette Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -215,7 +215,6 @@ md5_hmac_cleanup() { atf_test_case null cleanup null_head() { - atf_skip "NULL_CBC not implemented by swcrypto" common_head "Test NULL_CBC crypto" }
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Fri Jan 17 14:16:08 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_aesctr1.c h_aesctr2.c h_arc4.c h_camellia.c h_cbcdes.c h_gcm.c h_md5.c h_md5hmac.c h_null.c Log Message: Clean up the helper programs. Remove the code to print the results, and make sure that all helpers actually check the results against the correct values. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/crypto/opencrypto/h_aesctr1.c \ src/tests/crypto/opencrypto/h_aesctr2.c \ src/tests/crypto/opencrypto/h_arc4.c \ src/tests/crypto/opencrypto/h_camellia.c \ src/tests/crypto/opencrypto/h_cbcdes.c \ src/tests/crypto/opencrypto/h_gcm.c src/tests/crypto/opencrypto/h_md5.c \ src/tests/crypto/opencrypto/h_md5hmac.c \ src/tests/crypto/opencrypto/h_null.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_aesctr1.c diff -u src/tests/crypto/opencrypto/h_aesctr1.c:1.1 src/tests/crypto/opencrypto/h_aesctr1.c:1.2 --- src/tests/crypto/opencrypto/h_aesctr1.c:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/h_aesctr1.c Fri Jan 17 14:16:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_aesctr1.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ +/* $NetBSD: h_aesctr1.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -76,16 +76,9 @@ main(void) res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT"); -#if 1 + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) warnx("verification failed"); -#else - { - int i; - for (i = 0; i < sizeof(buf); i++) - printf("%02x ", buf[i]); - printf("\n"); - } -#endif + return 0; } Index: src/tests/crypto/opencrypto/h_aesctr2.c diff -u src/tests/crypto/opencrypto/h_aesctr2.c:1.1 src/tests/crypto/opencrypto/h_aesctr2.c:1.2 --- src/tests/crypto/opencrypto/h_aesctr2.c:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/h_aesctr2.c Fri Jan 17 14:16:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_aesctr2.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ +/* $NetBSD: h_aesctr2.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -89,16 +89,9 @@ main(void) res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT"); -#if 1 + if (memcmp((char *)co.dst + 8, plaintx, sizeof(plaintx))) warnx("verification failed"); -#else - { - int i; - for (i = 0; i < sizeof(ibuf); i++) - printf("%02x ", ibuf[i]); - printf("\n"); - } -#endif + return 0; } Index: src/tests/crypto/opencrypto/h_arc4.c diff -u src/tests/crypto/opencrypto/h_arc4.c:1.1 src/tests/crypto/opencrypto/h_arc4.c:1.2 --- src/tests/crypto/opencrypto/h_arc4.c:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/h_arc4.c Fri Jan 17 14:16:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_arc4.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ +/* $NetBSD: h_arc4.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -72,16 +72,9 @@ main(void) res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT"); -#if 1 + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) errx(1, "verification failed"); -#else - { - int i; - for (i = 0; i < sizeof(buf); i++) - printf("%02x ", buf[i]); - printf("\n"); - } -#endif + return 0; } Index: src/tests/crypto/opencrypto/h_camellia.c diff -u src/tests/crypto/opencrypto/h_camellia.c:1.1 src/tests/crypto/opencrypto/h_camellia.c:1.2 --- src/tests/crypto/opencrypto/h_camellia.c:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/h_camellia.c Fri Jan 17 14:16:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_camellia.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ +/* $NetBSD: h_camellia.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -78,16 +78,9 @@ main(void) res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT"); -#if 0 + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) warnx("verification failed"); -#else - { - unsigned int i; - for (i = 0; i < sizeof(buf); i++) - printf("%02x ", buf[i]); - printf("\n"); - } -#endif + return 0; } Index: src/tests/crypto/opencrypto/h_cbcdes.c diff -u src/tests/crypto/opencrypto/h_cbcdes.c:1.1 src/tests/crypto/opencrypto/h_cbcdes.c:1.2 --- src/tests/crypto/opencrypto/h_cbcdes.c:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/h_cbcdes.c Fri Jan 17 14:16:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_cbcdes.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ +/* $NetBSD: h_cbcdes.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -74,16 +74,9 @@ main(void) res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) err(1, "CIOCCRYPT"); -#if 1 + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) errx(1, "verification failed");
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Fri Jan 17 14:14:54 UTC 2014 Modified Files: src/tests/crypto/opencrypto: t_opencrypto.sh Log Message: Disable the arc4 and null_cbc tests for now. The swcrypto driver does not (yet) support them. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/crypto/opencrypto/t_opencrypto.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/t_opencrypto.sh diff -u src/tests/crypto/opencrypto/t_opencrypto.sh:1.1 src/tests/crypto/opencrypto/t_opencrypto.sh:1.2 --- src/tests/crypto/opencrypto/t_opencrypto.sh:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/t_opencrypto.sh Fri Jan 17 14:14:54 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ +# $NetBSD: t_opencrypto.sh,v 1.2 2014/01/17 14:14:54 pgoyette Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -75,6 +75,7 @@ arc4_head() { } arc4_body() { + atf_skip "ARC4 not implemented by swcrypto" common_body h_arc4 } @@ -214,6 +215,7 @@ md5_hmac_cleanup() { atf_test_case null cleanup null_head() { + atf_skip "NULL_CBC not implemented by swcrypto" common_head "Test NULL_CBC crypto" }
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: joerg Date: Thu Jan 16 23:56:04 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_xcbcmac.c Log Message: Use __arraycount and size_t as the format strings are wrong anyway. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/crypto/opencrypto/h_xcbcmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_xcbcmac.c diff -u src/tests/crypto/opencrypto/h_xcbcmac.c:1.3 src/tests/crypto/opencrypto/h_xcbcmac.c:1.4 --- src/tests/crypto/opencrypto/h_xcbcmac.c:1.3 Thu Jan 16 22:06:45 2014 +++ src/tests/crypto/opencrypto/h_xcbcmac.c Thu Jan 16 23:56:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_xcbcmac.c,v 1.3 2014/01/16 22:06:45 pgoyette Exp $ */ +/* $NetBSD: h_xcbcmac.c,v 1.4 2014/01/16 23:56:04 joerg Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ int main(void) { int fd, res; - unsigned int i; + size_t i; struct session_op cs; struct crypt_op co; unsigned char buf[16]; @@ -89,7 +89,7 @@ main(void) if (res < 0) err(1, "CIOCGSESSION"); - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { + for (i = 0; i < __arraycount(tests); i++) { memset(&co, 0, sizeof(co)); memset(buf, 0, sizeof(buf)); if (tests[i].len == sizeof(plaintx)) @@ -101,9 +101,9 @@ main(void) co.mac = buf; res = ioctl(fd, CIOCCRYPT, &co); if (res < 0) - err(1, "CIOCCRYPT test %d", i); + err(1, "CIOCCRYPT test %zu", i); if (memcmp(buf, &tests[i].mac, sizeof(tests[i].mac))) - errx(1, "verification failed test %d", i); + errx(1, "verification failed test %zu", i); } return 0; }
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Thu Jan 16 22:06:45 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_xcbcmac.c Log Message: Since sizeof() is unsigned, use an unsigned int for the loop index. Fixes latest build break. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/crypto/opencrypto/h_xcbcmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_xcbcmac.c diff -u src/tests/crypto/opencrypto/h_xcbcmac.c:1.2 src/tests/crypto/opencrypto/h_xcbcmac.c:1.3 --- src/tests/crypto/opencrypto/h_xcbcmac.c:1.2 Thu Jan 16 18:09:55 2014 +++ src/tests/crypto/opencrypto/h_xcbcmac.c Thu Jan 16 22:06:45 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_xcbcmac.c,v 1.2 2014/01/16 18:09:55 pgoyette Exp $ */ +/* $NetBSD: h_xcbcmac.c,v 1.3 2014/01/16 22:06:45 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -72,7 +72,8 @@ const struct { int main(void) { - int fd, res, i; + int fd, res; + unsigned int i; struct session_op cs; struct crypt_op co; unsigned char buf[16];
CVS commit: src/tests/crypto/opencrypto
Module Name:src Committed By: pgoyette Date: Thu Jan 16 18:09:55 UTC 2014 Modified Files: src/tests/crypto/opencrypto: h_xcbcmac.c Log Message: Include all of the examples from RFC3566 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/crypto/opencrypto/h_xcbcmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/crypto/opencrypto/h_xcbcmac.c diff -u src/tests/crypto/opencrypto/h_xcbcmac.c:1.1 src/tests/crypto/opencrypto/h_xcbcmac.c:1.2 --- src/tests/crypto/opencrypto/h_xcbcmac.c:1.1 Tue Jan 14 17:51:39 2014 +++ src/tests/crypto/opencrypto/h_xcbcmac.c Thu Jan 16 18:09:55 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_xcbcmac.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ +/* $NetBSD: h_xcbcmac.c,v 1.2 2014/01/16 18:09:55 pgoyette Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -36,20 +36,43 @@ #include + +/* test vectors from RFC3566 */ unsigned char key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; -char plaintx[] = {0x00, 0x01, 0x02}; -const unsigned char ciphertx[16] = { - 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, - 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +char plaintx[1000] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21 +}; +const struct { + size_t len; + unsigned char mac[12]; +} tests[] = { + {0, { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, + 0xc0, 0x1c, 0x45, 0x73, 0xdf, 0xd5 } }, + {3, { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, + 0x19, 0xaf, 0xe7, 0x21, 0x9c, 0xee } }, + { 16, { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, + 0x68, 0xa7, 0x99, 0x98, 0xa4, 0x39 } }, + { 20, { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, + 0x62, 0x15, 0xb8, 0x98, 0x5c, 0x63 } }, + { 32, { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, + 0xf3, 0xd3, 0x68, 0x07, 0x73, 0x4b } }, + { 34, { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, + 0x18, 0xa3, 0x06, 0x77, 0xd5, 0x48 } }, + { 1000, { 0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, + 0x30, 0x25, 0x37, 0x61, 0x10, 0x3b } }, }; int main(void) { - int fd, res; + int fd, res, i; struct session_op cs; struct crypt_op co; unsigned char buf[16]; @@ -65,26 +88,21 @@ main(void) if (res < 0) err(1, "CIOCGSESSION"); - memset(&co, 0, sizeof(co)); - memset(buf, 0, sizeof(buf)); - co.ses = cs.ses; - co.op = COP_ENCRYPT; - co.len = 0 /*sizeof(plaintx)*/; - co.src = plaintx; - co.mac = buf; - res = ioctl(fd, CIOCCRYPT, &co); - if (res < 0) - err(1, "CIOCCRYPT"); -#if 0 - if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) - errx(1, "verification failed"); -#else - { - unsigned int i; - for (i = 0; i < sizeof(buf); i++) - printf("%02x ", buf[i]); - printf("\n"); + for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + if (tests[i].len == sizeof(plaintx)) + memset(&plaintx, 0, sizeof(plaintx)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = plaintx; + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %d", i); + if (memcmp(buf, &tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %d", i); } -#endif return 0; }