diff options
author | lloyd <[email protected]> | 2009-11-17 07:19:37 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-17 07:19:37 +0000 |
commit | e00b46cf9c1dcb364ebb7d5968d6ff9dcd600c4e (patch) | |
tree | 8ffb8d032f06bbcb7ab376c7469751a25b556dca /src/modes/mode_pad/mode_pad.cpp | |
parent | a98a9ff5f95bd4dca9c1eda11e27e712c869cd66 (diff) |
Move most code that relies heavily on Filters into src/filters.
Remove support for (unused) modset settings.
Move tss, fpe, cryptobox, and aont to new dir constructs
Diffstat (limited to 'src/modes/mode_pad/mode_pad.cpp')
-rw-r--r-- | src/modes/mode_pad/mode_pad.cpp | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/src/modes/mode_pad/mode_pad.cpp b/src/modes/mode_pad/mode_pad.cpp deleted file mode 100644 index 2204c28b5..000000000 --- a/src/modes/mode_pad/mode_pad.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* -* CBC Padding Methods -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/mode_pad.h> -#include <botan/exceptn.h> - -namespace Botan { - -/* -* Default amount of padding -*/ -u32bit BlockCipherModePaddingMethod::pad_bytes(u32bit bs, u32bit pos) const - { - return (bs - pos); - } - -/* -* Pad with PKCS #7 Method -*/ -void PKCS7_Padding::pad(byte block[], u32bit size, u32bit position) const - { - for(u32bit j = 0; j != size; ++j) - block[j] = (size-position); - } - -/* -* Unpad with PKCS #7 Method -*/ -u32bit PKCS7_Padding::unpad(const byte block[], u32bit size) const - { - u32bit position = block[size-1]; - if(position > size) - throw Decoding_Error(name()); - for(u32bit j = size-position; j != size-1; ++j) - if(block[j] != position) - throw Decoding_Error(name()); - return (size-position); - } - -/* -* Query if the size is valid for this method -*/ -bool PKCS7_Padding::valid_blocksize(u32bit size) const - { - if(size > 0 && size < 256) - return true; - else - return false; - } - -/* -* Pad with ANSI X9.23 Method -*/ -void ANSI_X923_Padding::pad(byte block[], u32bit size, u32bit position) const - { - for(u32bit j = 0; j != size-position; ++j) - block[j] = 0; - block[size-position-1] = (size-position); - } - -/* -* Unpad with ANSI X9.23 Method -*/ -u32bit ANSI_X923_Padding::unpad(const byte block[], u32bit size) const - { - u32bit position = block[size-1]; - if(position > size) - throw Decoding_Error(name()); - for(u32bit j = size-position; j != size-1; ++j) - if(block[j] != 0) - throw Decoding_Error(name()); - return (size-position); - } - -/* -* Query if the size is valid for this method -*/ -bool ANSI_X923_Padding::valid_blocksize(u32bit size) const - { - if(size > 0 && size < 256) - return true; - else - return false; - } - -/* -* Pad with One and Zeros Method -*/ -void OneAndZeros_Padding::pad(byte block[], u32bit size, u32bit) const - { - block[0] = 0x80; - for(u32bit j = 1; j != size; ++j) - block[j] = 0x00; - } - -/* -* Unpad with One and Zeros Method -*/ -u32bit OneAndZeros_Padding::unpad(const byte block[], u32bit size) const - { - while(size) - { - if(block[size-1] == 0x80) - break; - if(block[size-1] != 0x00) - throw Decoding_Error(name()); - size--; - } - if(!size) - throw Decoding_Error(name()); - return (size-1); - } - -/* -* Query if the size is valid for this method -*/ -bool OneAndZeros_Padding::valid_blocksize(u32bit size) const - { - if(size) return true; - else return false; - } - -} |