Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/external/bsd/netpgp/dist added blowfish symmetric cip...
details: https://anonhg.NetBSD.org/src/rev/cc6e6cf5f30f
branches: trunk
changeset: 971227:cc6e6cf5f30f
user: jhigh <jhigh%NetBSD.org@localhost>
date: Sat Apr 18 19:27:48 2020 +0000
description:
added blowfish symmetric cipher per RFC4880 9.2
diffstat:
crypto/external/bsd/netpgp/dist/configure.ac | 6 +-
crypto/external/bsd/netpgp/dist/src/lib/config.h.in | 6 +-
crypto/external/bsd/netpgp/dist/src/lib/misc.c | 3 +-
crypto/external/bsd/netpgp/dist/src/lib/symmetric.c | 89 ++++++++++++++++++++-
4 files changed, 97 insertions(+), 7 deletions(-)
diffs (195 lines):
diff -r f311aa48e92c -r cc6e6cf5f30f crypto/external/bsd/netpgp/dist/configure.ac
--- a/crypto/external/bsd/netpgp/dist/configure.ac Sat Apr 18 19:18:33 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/configure.ac Sat Apr 18 19:27:48 2020 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: configure.ac,v 1.42 2014/03/09 00:33:50 agc Exp $
+# $NetBSD: configure.ac,v 1.43 2020/04/18 19:27:49 jhigh Exp $
#
# Process this file with autoconf to produce a configure script.
AC_INIT([netpgp],[20140220],[Alistair Crooks <agc%netbsd.org@localhost> c0596823])
AC_PREREQ(2.69)
-AC_REVISION([$Revision: 1.42 $])
+AC_REVISION([$Revision: 1.43 $])
AS_SHELL_SANITIZE
@@ -60,7 +60,7 @@
AC_CHECK_HEADERS([openssl/aes.h openssl/bn.h openssl/camellia.h openssl/cast.h \
openssl/des.h openssl/dsa.h openssl/err.h openssl/idea.h \
openssl/md5.h openssl/rand.h openssl/rsa.h openssl/sha.h \
- openssl/err.h openssl/sha.h])
+ openssl/err.h openssl/sha.h openssl/blowfish.h])
AC_CHECK_HEADERS([sys/cdefs.h sys/file.h sys/mman.h sys/param.h \
sys/resource.h sys/uio.h])
diff -r f311aa48e92c -r cc6e6cf5f30f crypto/external/bsd/netpgp/dist/src/lib/config.h.in
--- a/crypto/external/bsd/netpgp/dist/src/lib/config.h.in Sat Apr 18 19:18:33 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/config.h.in Sat Apr 18 19:27:48 2020 +0000
@@ -39,6 +39,9 @@
/* Define to 1 if you have the <openssl/aes.h> header file. */
#undef HAVE_OPENSSL_AES_H
+/* Define to 1 if you have the <openssl/blowfish.h> header file. */
+#undef HAVE_OPENSSL_BLOWFISH_H
+
/* Define to 1 if you have the <openssl/bn.h> header file. */
#undef HAVE_OPENSSL_BN_H
@@ -120,8 +123,7 @@
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Name of package */
diff -r f311aa48e92c -r cc6e6cf5f30f crypto/external/bsd/netpgp/dist/src/lib/misc.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/misc.c Sat Apr 18 19:18:33 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/misc.c Sat Apr 18 19:27:48 2020 +0000
@@ -57,7 +57,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: misc.c,v 1.42 2018/11/13 14:52:30 mlelstv Exp $");
+__RCSID("$NetBSD: misc.c,v 1.43 2020/04/18 19:27:48 jhigh Exp $");
#endif
#include <sys/types.h>
@@ -816,6 +816,7 @@
{ "idea", PGP_SA_IDEA },
{ "aes128", PGP_SA_AES_128 },
{ "aes256", PGP_SA_AES_256 },
+ { "blowfish", PGP_SA_BLOWFISH },
{ "camellia128", PGP_SA_CAMELLIA_128 },
{ "camellia256", PGP_SA_CAMELLIA_256 },
{ "tripledes", PGP_SA_TRIPLEDES },
diff -r f311aa48e92c -r cc6e6cf5f30f crypto/external/bsd/netpgp/dist/src/lib/symmetric.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/symmetric.c Sat Apr 18 19:18:33 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/symmetric.c Sat Apr 18 19:27:48 2020 +0000
@@ -54,7 +54,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: symmetric.c,v 1.18 2010/11/07 08:39:59 agc Exp $");
+__RCSID("$NetBSD: symmetric.c,v 1.19 2020/04/18 19:27:48 jhigh Exp $");
#endif
#include "crypto.h"
@@ -82,6 +82,10 @@
#include <openssl/camellia.h>
#endif
+#ifdef HAVE_OPENSSL_BLOWFISH_H
+#include <openssl/blowfish.h>
+#endif
+
#include "crypto.h"
#include "netpgpdefs.h"
@@ -192,6 +196,81 @@
TRAILER
};
+#ifdef HAVE_OPENSSL_BLOWFISH_H
+
+/* RFC 4880 9.2 Blowfish 128 */
+#define BLOWFISH_KEY_LENGTH 16
+
+static int
+blowfish_init(pgp_crypt_t *crypt)
+{
+ if (crypt->encrypt_key) {
+ free(crypt->encrypt_key);
+ }
+ if (crypt->keysize != BLOWFISH_KEY_LENGTH) {
+ (void) fprintf(stderr, "blowfish_init: keysize wrong\n");
+ return 0;
+ }
+ if ((crypt->encrypt_key = calloc(1, sizeof(BF_KEY))) == NULL) {
+ (void) fprintf(stderr, "blowfish_init: alloc failure\n");
+ return 0;
+ }
+ BF_set_key(crypt->encrypt_key, (int)crypt->keysize, crypt->key);
+ if ((crypt->decrypt_key = calloc(1, sizeof(BF_KEY))) == NULL) {
+ (void) fprintf(stderr, "blowfish_init: alloc failure\n");
+ return 0;
+ }
+ BF_set_key(crypt->decrypt_key, (int)crypt->keysize, crypt->key);
+ return 1;
+}
+
+static void
+blowfish_block_encrypt(pgp_crypt_t *crypt, void *out, const void *in)
+{
+ BF_ecb_encrypt(in, out, crypt->encrypt_key, BF_ENCRYPT);
+}
+
+static void
+blowfish_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
+{
+ BF_ecb_encrypt(in, out, crypt->encrypt_key, BF_DECRYPT);
+}
+
+static void
+blowfish_cfb_encrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
+{
+ BF_cfb64_encrypt(in, out, (long)count,
+ crypt->encrypt_key, crypt->iv, &crypt->num,
+ BF_ENCRYPT);
+}
+
+static void
+blowfish_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
+{
+ BF_cfb64_encrypt(in, out, (long)count,
+ crypt->encrypt_key, crypt->iv, &crypt->num,
+ BF_DECRYPT);
+}
+
+static pgp_crypt_t blowfish =
+{
+ PGP_SA_BLOWFISH,
+ BF_BLOCK,
+ BLOWFISH_KEY_LENGTH,
+ std_set_iv,
+ std_set_key,
+ blowfish_init,
+ std_resync,
+ blowfish_block_encrypt,
+ blowfish_block_decrypt,
+ blowfish_cfb_encrypt,
+ blowfish_cfb_decrypt,
+ std_finish,
+ TRAILER
+};
+
+#endif /* HAVE_OPENSSL_BLOWFISH_H */
+
#ifndef OPENSSL_NO_IDEA
static int
idea_init(pgp_crypt_t *crypt)
@@ -633,6 +712,11 @@
#endif
case PGP_SA_TRIPLEDES:
return &tripledes;
+#if defined HAVE_OPENSSL_BLOWFISH_H
+ case PGP_SA_BLOWFISH:
+ return &blowfish;
+#endif
+
default:
(void) fprintf(stderr, "Unknown algorithm: %d (%s)\n",
alg, pgp_show_symm_alg(alg));
@@ -756,6 +840,9 @@
case PGP_SA_AES_128:
case PGP_SA_AES_256:
case PGP_SA_CAST5:
+#if defined(HAVE_OPENSSL_BLOWFISH_H)
+ case PGP_SA_BLOWFISH:
+#endif
case PGP_SA_TRIPLEDES:
#if defined(HAVE_OPENSSL_CAMELLIA_H) && !defined(OPENSSL_NO_CAMELLIA)
case PGP_SA_CAMELLIA_128:
Home |
Main Index |
Thread Index |
Old Index