[libtomcrypt/epel7] Add two-key 3DES support, needed by pycrypto.

Simone Caronni slaanesh at fedoraproject.org
Thu May 15 15:02:29 UTC 2014


commit 62d67214949723a3a972c086d136c0f05aad2d46
Author: Simone Caronni <negativo17 at gmail.com>
Date:   Thu May 15 17:02:17 2014 +0200

    Add two-key 3DES support, needed by pycrypto.

 libtomcrypt-two-key-triple-des.patch |   53 ++++++++++++++++++++++++++++++++++
 libtomcrypt.spec                     |   11 +++++--
 2 files changed, 61 insertions(+), 3 deletions(-)
---
diff --git a/libtomcrypt-two-key-triple-des.patch b/libtomcrypt-two-key-triple-des.patch
new file mode 100644
index 0000000..9a48a20
--- /dev/null
+++ b/libtomcrypt-two-key-triple-des.patch
@@ -0,0 +1,53 @@
+From 445dfa67a64dcd30067dab823f6bae31d1019c1e Mon Sep 17 00:00:00 2001
+From: Paul Howarth <paul at city-fan.org>
+Date: Tue, 15 Apr 2014 11:25:18 +0100
+Subject: [PATCH] des.c: Add support for two-key Triple-DES
+
+Add two-key 3DES support, needed by pycrypto.
+
+This commit is based on the one for the bundled libtomcrypt 1.16
+code in pycrypto:
+
+https://github.com/dlitz/pycrypto/commit/65085f16
+---
+ src/ciphers/des.c | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/src/ciphers/des.c b/src/ciphers/des.c
+index af3a4d0..0034c80 100644
+--- a/src/ciphers/des.c
++++ b/src/ciphers/des.c
+@@ -1562,17 +1562,27 @@ int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_k
+         return CRYPT_INVALID_ROUNDS;
+     }
+ 
+-    if (keylen != 24) {
++    if (keylen != 24 && keylen != 16) {
+         return CRYPT_INVALID_KEYSIZE;
+     }
+ 
+     deskey(key,    EN0, skey->des3.ek[0]);
+     deskey(key+8,  DE1, skey->des3.ek[1]);
+-    deskey(key+16, EN0, skey->des3.ek[2]);
++    if (keylen == 24) {
++        deskey(key+16, EN0, skey->des3.ek[2]);
++    } else {
++        /* two-key 3DES: K3=K1 */
++        deskey(key, EN0, skey->des3.ek[2]);
++    }
+ 
+     deskey(key,    DE1, skey->des3.dk[2]);
+     deskey(key+8,  EN0, skey->des3.dk[1]);
+-    deskey(key+16, DE1, skey->des3.dk[0]);
++    if (keylen == 24) {
++        deskey(key+16, DE1, skey->des3.dk[0]);
++    } else {
++        /* two-key 3DES: K3=K1 */
++        deskey(key, DE1, skey->des3.dk[0]);
++    }
+ 
+     return CRYPT_OK;
+ }
+-- 
+1.9.0
+
diff --git a/libtomcrypt.spec b/libtomcrypt.spec
index 0c9667e..0e14bb7 100644
--- a/libtomcrypt.spec
+++ b/libtomcrypt.spec
@@ -1,6 +1,6 @@
 Name:           libtomcrypt
 Version:        1.17
-Release:        21%{?dist}
+Release:        22%{?dist}
 Summary:        A comprehensive, portable cryptographic toolkit
 
 License:        Public Domain
@@ -8,6 +8,7 @@ URL:            http://www.libtom.org/?page=features&newsitems=5&whatfile=crypt
 Source0:        http://www.libtom.org/files/crypt-%{version}.tar.bz2
 Patch0:         %{name}-makefile.patch
 Patch1:         %{name}-pkgconfig.patch
+Patch2:         %{name}-two-key-triple-des.patch
 
 BuildRequires:  ghostscript
 BuildRequires:  libtommath-devel >= 0.42.0-3
@@ -54,8 +55,9 @@ The %{name}-doc package contains documentation for use with %{name}.
 
 %prep
 %setup -q
-%patch0 -p1 -b .makefile
-%patch1 -p1 -b .pkgconfig
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 # No configure script ships with libtomcrypt. Its only requirement is ANSI C and
@@ -104,6 +106,9 @@ find %{buildroot} -name 'libtomcrypt_prof*' -delete
 %doc LICENSE doc/crypt.pdf
 
 %changelog
+* Thu May 15 2014 Paul Howarth <paul at city-fan.org> - 1.17-22
+- Add two-key 3DES support, needed by pycrypto.
+
 * Sun Sep 29 2013 Simone Caronni <negativo17 at gmail.com> - 1.17-21
 - Move headers to default location.
 


More information about the scm-commits mailing list