aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-09-26 13:08:38 -0400
committerJack Lloyd <[email protected]>2020-11-05 10:40:42 -0500
commitd802f619e18b4976bb2556d34620536b8481f817 (patch)
tree02fde1ef84c5dc347fbabf35554e7d2ac01f4360 /src
parent4abcc60af655347c9a004cf237d1356d71b7ee3e (diff)
Remove all or nothing transform
Diffstat (limited to 'src')
-rw-r--r--src/lib/misc/aont/info.txt9
-rw-r--r--src/lib/misc/aont/package.cpp125
-rw-r--r--src/lib/misc/aont/package.h49
3 files changed, 0 insertions, 183 deletions
diff --git a/src/lib/misc/aont/info.txt b/src/lib/misc/aont/info.txt
deleted file mode 100644
index bbd6449f7..000000000
--- a/src/lib/misc/aont/info.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-<defines>
-PACKAGE_TRANSFORM -> 20131128
-</defines>
-
-<requires>
-ctr
-rng
-filters
-</requires>
diff --git a/src/lib/misc/aont/package.cpp b/src/lib/misc/aont/package.cpp
deleted file mode 100644
index 7cadc62f4..000000000
--- a/src/lib/misc/aont/package.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-* Rivest's Package Tranform
-*
-* (C) 2009 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/package.h>
-#include <botan/filters.h>
-#include <botan/ctr.h>
-#include <botan/loadstor.h>
-#include <botan/rng.h>
-
-namespace Botan {
-
-void aont_package(RandomNumberGenerator& rng,
- BlockCipher* cipher,
- const uint8_t input[], size_t input_len,
- uint8_t output[])
- {
- if(input_len <= 1)
- throw Encoding_Error("Package transform cannot encode small inputs");
-
- const size_t BLOCK_SIZE = cipher->block_size();
-
- if(!cipher->valid_keylength(BLOCK_SIZE))
- throw Invalid_Argument("AONT::package: Invalid cipher");
-
- // The all-zero string which is used both as the CTR IV and as K0
- const std::string all_zeros(BLOCK_SIZE*2, '0');
-
- SymmetricKey package_key(rng, BLOCK_SIZE);
-
- Pipe pipe(new StreamCipher_Filter(new CTR_BE(cipher), package_key));
-
- pipe.process_msg(input, input_len);
- const size_t remaining = pipe.remaining();
- BOTAN_ASSERT_EQUAL(remaining, pipe.read(output, remaining), "Expected read size");
-
- // Set K0 (the all zero key)
- cipher->set_key(SymmetricKey(all_zeros));
-
- secure_vector<uint8_t> buf(BLOCK_SIZE);
-
- const size_t blocks =
- (input_len + BLOCK_SIZE - 1) / BLOCK_SIZE;
-
- uint8_t* final_block = output + input_len;
- clear_mem(final_block, BLOCK_SIZE);
-
- // XOR the hash blocks into the final block
- for(size_t i = 0; i != blocks; ++i)
- {
- const size_t left = std::min<size_t>(BLOCK_SIZE,
- input_len - BLOCK_SIZE * i);
-
- zeroise(buf);
- copy_mem(buf.data(), output + (BLOCK_SIZE * i), left);
-
- for(size_t j = 0; j != sizeof(i); ++j)
- buf[BLOCK_SIZE - 1 - j] ^= get_byte(sizeof(i)-1-j, i);
-
- cipher->encrypt(buf.data());
-
- xor_buf(final_block, buf.data(), BLOCK_SIZE);
- }
-
- // XOR the random package key into the final block
- xor_buf(final_block, package_key.begin(), BLOCK_SIZE);
- }
-
-void aont_unpackage(BlockCipher* cipher,
- const uint8_t input[], size_t input_len,
- uint8_t output[])
- {
- const size_t BLOCK_SIZE = cipher->block_size();
-
- if(!cipher->valid_keylength(BLOCK_SIZE))
- throw Invalid_Argument("AONT::unpackage: Invalid cipher");
-
- if(input_len < BLOCK_SIZE)
- throw Invalid_Argument("AONT::unpackage: Input too short");
-
- // The all-zero string which is used both as the CTR IV and as K0
- const std::string all_zeros(BLOCK_SIZE*2, '0');
-
- cipher->set_key(SymmetricKey(all_zeros));
-
- secure_vector<uint8_t> package_key(BLOCK_SIZE);
- secure_vector<uint8_t> buf(BLOCK_SIZE);
-
- // Copy the package key (masked with the block hashes)
- copy_mem(package_key.data(),
- input + (input_len - BLOCK_SIZE),
- BLOCK_SIZE);
-
- const size_t blocks = ((input_len - 1) / BLOCK_SIZE);
-
- // XOR the blocks into the package key bits
- for(size_t i = 0; i != blocks; ++i)
- {
- const size_t left = std::min<size_t>(BLOCK_SIZE,
- input_len - BLOCK_SIZE * (i+1));
-
- zeroise(buf);
- copy_mem(buf.data(), input + (BLOCK_SIZE * i), left);
-
- for(size_t j = 0; j != sizeof(i); ++j)
- buf[BLOCK_SIZE - 1 - j] ^= get_byte(sizeof(i)-1-j, i);
-
- cipher->encrypt(buf.data());
-
- xor_buf(package_key.data(), buf.data(), BLOCK_SIZE);
- }
-
- Pipe pipe(new StreamCipher_Filter(new CTR_BE(cipher), package_key));
-
- pipe.process_msg(input, input_len - BLOCK_SIZE);
-
- const size_t remaining = pipe.remaining();
- BOTAN_ASSERT_EQUAL(remaining, pipe.read(output, remaining), "Expected read size");
- }
-
-}
diff --git a/src/lib/misc/aont/package.h b/src/lib/misc/aont/package.h
deleted file mode 100644
index 38e04e470..000000000
--- a/src/lib/misc/aont/package.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Rivest's Package Tranform
-* (C) 2009 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_AONT_PACKAGE_TRANSFORM_H_
-#define BOTAN_AONT_PACKAGE_TRANSFORM_H_
-
-#include <botan/block_cipher.h>
-
-namespace Botan {
-
-class RandomNumberGenerator;
-
-/**
-* Rivest's Package Tranform
-* @param rng the random number generator to use
-* @param cipher the block cipher to use (aont_package takes ownership)
-* @param input the input data buffer
-* @param input_len the length of the input data in bytes
-* @param output the output data buffer (must be at least
-* input_len + cipher->BLOCK_SIZE bytes long)
-*/
-BOTAN_DEPRECATED("Possibly broken, avoid")
-void BOTAN_PUBLIC_API(2,0)
-aont_package(RandomNumberGenerator& rng,
- BlockCipher* cipher,
- const uint8_t input[], size_t input_len,
- uint8_t output[]);
-
-/**
-* Rivest's Package Tranform (Inversion)
-* @param cipher the block cipher to use (aont_package takes ownership)
-* @param input the input data buffer
-* @param input_len the length of the input data in bytes
-* @param output the output data buffer (must be at least
-* input_len - cipher->BLOCK_SIZE bytes long)
-*/
-BOTAN_DEPRECATED("Possibly broken, avoid")
-void BOTAN_PUBLIC_API(2,0)
-aont_unpackage(BlockCipher* cipher,
- const uint8_t input[], size_t input_len,
- uint8_t output[]);
-
-}
-
-#endif