aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/constructs/rfc3394
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-05 07:44:25 +0000
committerlloyd <[email protected]>2015-02-05 07:44:25 +0000
commitcb0f83ae63c4555cbdd0607e3a5f6e9260c0d19c (patch)
tree4981027a25fa8074177b97c3a3ca7431f3337deb /src/lib/constructs/rfc3394
parent2c14faf0aa1cfe0f8d70af1938dcad5b4d6d3b59 (diff)
Clean up root dir, remove some unneeded dependencies
Diffstat (limited to 'src/lib/constructs/rfc3394')
-rw-r--r--src/lib/constructs/rfc3394/info.txt5
-rw-r--r--src/lib/constructs/rfc3394/rfc3394.cpp119
-rw-r--r--src/lib/constructs/rfc3394/rfc3394.h40
3 files changed, 0 insertions, 164 deletions
diff --git a/src/lib/constructs/rfc3394/info.txt b/src/lib/constructs/rfc3394/info.txt
deleted file mode 100644
index 8cd5989ca..000000000
--- a/src/lib/constructs/rfc3394/info.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-define RFC3394_KEYWRAP 20131128
-
-<requires>
-aes
-</requires>
diff --git a/src/lib/constructs/rfc3394/rfc3394.cpp b/src/lib/constructs/rfc3394/rfc3394.cpp
deleted file mode 100644
index 422f2a2dd..000000000
--- a/src/lib/constructs/rfc3394/rfc3394.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* AES Key Wrap (RFC 3394)
-* (C) 2011 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/rfc3394.h>
-#include <botan/internal/algo_registry.h>
-#include <botan/block_cipher.h>
-#include <botan/loadstor.h>
-#include <botan/exceptn.h>
-#include <botan/internal/xor_buf.h>
-
-namespace Botan {
-
-namespace {
-
-BlockCipher* make_aes(size_t keylength)
- {
- auto& block_ciphers = Algo_Registry<BlockCipher>::global_registry();
- if(keylength == 16)
- return block_ciphers.make("AES-128");
- else if(keylength == 24)
- return block_ciphers.make("AES-192");
- else if(keylength == 32)
- return block_ciphers.make("AES-256");
- else
- throw std::invalid_argument("Bad KEK length for NIST keywrap");
- }
-
-}
-
-secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
- const SymmetricKey& kek)
- {
- if(key.size() % 8 != 0)
- throw std::invalid_argument("Bad input key size for NIST key wrap");
-
- std::unique_ptr<BlockCipher> aes(make_aes(kek.length()));
- aes->set_key(kek);
-
- const size_t n = key.size() / 8;
-
- secure_vector<byte> R((n + 1) * 8);
- secure_vector<byte> A(16);
-
- for(size_t i = 0; i != 8; ++i)
- A[i] = 0xA6;
-
- copy_mem(&R[8], &key[0], key.size());
-
- for(size_t j = 0; j <= 5; ++j)
- {
- for(size_t i = 1; i <= n; ++i)
- {
- const u32bit t = (n * j) + i;
-
- copy_mem(&A[8], &R[8*i], 8);
-
- aes->encrypt(&A[0]);
- copy_mem(&R[8*i], &A[8], 8);
-
- byte t_buf[4] = { 0 };
- store_be(t, t_buf);
- xor_buf(&A[4], &t_buf[0], 4);
- }
- }
-
- copy_mem(&R[0], &A[0], 8);
-
- return R;
- }
-
-secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
- const SymmetricKey& kek)
- {
- if(key.size() < 16 || key.size() % 8 != 0)
- throw std::invalid_argument("Bad input key size for NIST key unwrap");
-
- std::unique_ptr<BlockCipher> aes(make_aes(kek.length()));
- aes->set_key(kek);
-
- const size_t n = (key.size() - 8) / 8;
-
- secure_vector<byte> R(n * 8);
- secure_vector<byte> A(16);
-
- for(size_t i = 0; i != 8; ++i)
- A[i] = key[i];
-
- copy_mem(&R[0], &key[8], key.size() - 8);
-
- for(size_t j = 0; j <= 5; ++j)
- {
- for(size_t i = n; i != 0; --i)
- {
- const u32bit t = (5 - j) * n + i;
-
- byte t_buf[4] = { 0 };
- store_be(t, t_buf);
-
- xor_buf(&A[4], &t_buf[0], 4);
-
- copy_mem(&A[8], &R[8*(i-1)], 8);
-
- aes->decrypt(&A[0]);
-
- copy_mem(&R[8*(i-1)], &A[8], 8);
- }
- }
-
- if(load_be<u64bit>(&A[0], 0) != 0xA6A6A6A6A6A6A6A6)
- throw Integrity_Failure("NIST key unwrap failed");
-
- return R;
- }
-
-}
diff --git a/src/lib/constructs/rfc3394/rfc3394.h b/src/lib/constructs/rfc3394/rfc3394.h
deleted file mode 100644
index fab6bc3cb..000000000
--- a/src/lib/constructs/rfc3394/rfc3394.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* AES Key Wrap (RFC 3394)
-* (C) 2011 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_AES_KEY_WRAP_H__
-#define BOTAN_AES_KEY_WRAP_H__
-
-#include <botan/symkey.h>
-
-namespace Botan {
-
-/**
-* Encrypt a key under a key encryption key using the algorithm
-* described in RFC 3394
-*
-* @param key the plaintext key to encrypt
-* @param kek the key encryption key
-* @return key encrypted under kek
-*/
-secure_vector<byte> BOTAN_DLL rfc3394_keywrap(const secure_vector<byte>& key,
- const SymmetricKey& kek);
-
-/**
-* Decrypt a key under a key encryption key using the algorithm
-* described in RFC 3394
-*
-* @param key the encrypted key to decrypt
-* @param kek the key encryption key
-* @param af an algorithm factory
-* @return key decrypted under kek
-*/
-secure_vector<byte> BOTAN_DLL rfc3394_keyunwrap(const secure_vector<byte>& key,
- const SymmetricKey& kek);
-
-}
-
-#endif