monotone

monotone Mtn Source Tree

Root/botan/des.h

1/*************************************************
2* DES Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_DES_H__
7#define BOTAN_DES_H__
8
9#include <botan/base.h>
10
11namespace Botan {
12
13/*************************************************
14* DES *
15*************************************************/
16class DES : public BlockCipher
17 {
18 public:
19 void clear() throw() { round_key.clear(); }
20 std::string name() const { return "DES"; }
21 BlockCipher* clone() const { return new DES; }
22 DES() : BlockCipher(8, 8) {}
23 private:
24 friend class TripleDES;
25
26 void enc(const byte[], byte[]) const;
27 void dec(const byte[], byte[]) const;
28 void key(const byte[], u32bit);
29 void raw_encrypt(u32bit&, u32bit&) const;
30 void raw_decrypt(u32bit&, u32bit&) const;
31 void round(u32bit&, u32bit, u32bit) const;
32 static void IP(u32bit&, u32bit&);
33 static void FP(u32bit&, u32bit&);
34
35 static const u32bit SPBOX1[256], SPBOX2[256], SPBOX3[256], SPBOX4[256],
36 SPBOX5[256], SPBOX6[256], SPBOX7[256], SPBOX8[256];
37 static const u64bit IPTAB1[256], IPTAB2[256], FPTAB1[256], FPTAB2[256];
38
39 SecureBuffer<u32bit, 32> round_key;
40 };
41
42/*************************************************
43* Triple DES *
44*************************************************/
45class TripleDES : public BlockCipher
46 {
47 public:
48 void clear() throw() { des1.clear(); des2.clear(); des3.clear(); }
49 std::string name() const { return "TripleDES"; }
50 BlockCipher* clone() const { return new TripleDES; }
51 TripleDES() : BlockCipher(8, 16, 24, 8) {}
52 private:
53 void enc(const byte[], byte[]) const;
54 void dec(const byte[], byte[]) const;
55 void key(const byte[], u32bit);
56 DES des1, des2, des3;
57 };
58
59/*************************************************
60* DESX *
61*************************************************/
62class DESX : public BlockCipher
63 {
64 public:
65 void clear() throw() { des.clear(); K1.clear(); K2.clear(); }
66 std::string name() const { return "DESX"; }
67 BlockCipher* clone() const { return new DESX; }
68 DESX() : BlockCipher(8, 24) {}
69 private:
70 void enc(const byte[], byte[]) const;
71 void dec(const byte[], byte[]) const;
72 void key(const byte[], u32bit);
73 SecureBuffer<byte, 8> K1, K2;
74 DES des;
75 };
76
77}
78
79#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status