aboutsummaryrefslogtreecommitdiffstats
path: root/src/modes
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-08-19 14:31:17 +0000
committerlloyd <[email protected]>2013-08-19 14:31:17 +0000
commit394033c9fe998dc6a64162414bbc2b705f1ec901 (patch)
tree0c5f8331cde1296a2c266800cbc5c594d128098d /src/modes
parent178fe54130c3582e5a292bac063f53a77dc4c4df (diff)
Add Cipher_Mode intermediate class. Add missing BOTAN_DLL exports
Diffstat (limited to 'src/modes')
-rw-r--r--src/modes/aead/aead.h8
-rw-r--r--src/modes/cbc/cbc.h4
-rw-r--r--src/modes/cfb/cfb.h4
-rw-r--r--src/modes/cipher_mode.h30
-rw-r--r--src/modes/ecb/ecb.h6
-rw-r--r--src/modes/xts/xts.h4
6 files changed, 44 insertions, 12 deletions
diff --git a/src/modes/aead/aead.h b/src/modes/aead/aead.h
index 97f156d60..25958a36a 100644
--- a/src/modes/aead/aead.h
+++ b/src/modes/aead/aead.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_AEAD_MODE_H__
#define BOTAN_AEAD_MODE_H__
-#include <botan/transform.h>
+#include <botan/cipher_mode.h>
namespace Botan {
@@ -19,9 +19,11 @@ namespace Botan {
* which is not included in the ciphertext (for instance a sequence
* number).
*/
-class AEAD_Mode : public Transformation
+class BOTAN_DLL AEAD_Mode : public Cipher_Mode
{
public:
+ bool authenticated() const override { return true; }
+
/**
* Set associated data that is not included in the ciphertext but
* that should be authenticated. Must be called after set_key
@@ -44,7 +46,7 @@ class AEAD_Mode : public Transformation
/**
* Default AEAD nonce size (a commonly supported value among AEAD
- * modes, and, large enough that random collisions are unlikely).
+ * modes, and large enough that random collisions are unlikely).
*/
size_t default_nonce_size() const override { return 12; }
};
diff --git a/src/modes/cbc/cbc.h b/src/modes/cbc/cbc.h
index 68a1f7bcd..8638c8a05 100644
--- a/src/modes/cbc/cbc.h
+++ b/src/modes/cbc/cbc.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_MODE_CBC_H__
#define BOTAN_MODE_CBC_H__
-#include <botan/transform.h>
+#include <botan/cipher_mode.h>
#include <botan/block_cipher.h>
#include <botan/mode_pad.h>
#include <memory>
@@ -18,7 +18,7 @@ namespace Botan {
/**
* CBC Mode
*/
-class CBC_Mode : public Transformation
+class BOTAN_DLL CBC_Mode : public Cipher_Mode
{
public:
secure_vector<byte> start(const byte nonce[], size_t nonce_len) override;
diff --git a/src/modes/cfb/cfb.h b/src/modes/cfb/cfb.h
index 19e5b4bb0..46b1997d2 100644
--- a/src/modes/cfb/cfb.h
+++ b/src/modes/cfb/cfb.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_MODE_CFB_H__
#define BOTAN_MODE_CFB_H__
-#include <botan/transform.h>
+#include <botan/cipher_mode.h>
#include <botan/block_cipher.h>
#include <botan/mode_pad.h>
#include <memory>
@@ -18,7 +18,7 @@ namespace Botan {
/**
* CFB Mode
*/
-class CFB_Mode : public Transformation
+class BOTAN_DLL CFB_Mode : public Cipher_Mode
{
public:
secure_vector<byte> start(const byte nonce[], size_t nonce_len) override;
diff --git a/src/modes/cipher_mode.h b/src/modes/cipher_mode.h
new file mode 100644
index 000000000..91e2af5a9
--- /dev/null
+++ b/src/modes/cipher_mode.h
@@ -0,0 +1,30 @@
+/*
+* Cipher Modes
+* (C) 2013 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_CIPHER_MODE_H__
+#define BOTAN_CIPHER_MODE_H__
+
+#include <botan/transform.h>
+
+namespace Botan {
+
+/**
+* Interface for cipher modes
+*/
+class BOTAN_DLL Cipher_Mode : public Transformation
+ {
+ public:
+ /**
+ * Returns true iff this mode provides authentication as well as
+ * confidentiality.
+ */
+ virtual bool authenticated() const { return false; }
+ };
+
+}
+
+#endif
diff --git a/src/modes/ecb/ecb.h b/src/modes/ecb/ecb.h
index 459ac939a..8ab62fa45 100644
--- a/src/modes/ecb/ecb.h
+++ b/src/modes/ecb/ecb.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_MODE_ECB_H__
#define BOTAN_MODE_ECB_H__
-#include <botan/transform.h>
+#include <botan/cipher_mode.h>
#include <botan/block_cipher.h>
#include <botan/mode_pad.h>
#include <memory>
@@ -16,9 +16,9 @@
namespace Botan {
/**
-* ECB Mode. Only handles full blocks, padding is handled higher up
+* ECB mode
*/
-class ECB_Mode : public Transformation
+class BOTAN_DLL ECB_Mode : public Cipher_Mode
{
public:
secure_vector<byte> start(const byte nonce[], size_t nonce_len) override;
diff --git a/src/modes/xts/xts.h b/src/modes/xts/xts.h
index 0aea3293d..a1f0f1626 100644
--- a/src/modes/xts/xts.h
+++ b/src/modes/xts/xts.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_MODE_XTS_H__
#define BOTAN_MODE_XTS_H__
-#include <botan/transform.h>
+#include <botan/cipher_mode.h>
#include <botan/block_cipher.h>
#include <memory>
@@ -17,7 +17,7 @@ namespace Botan {
/**
* IEEE P1619 XTS Mode
*/
-class XTS_Mode : public Transformation
+class BOTAN_DLL XTS_Mode : public Cipher_Mode
{
public:
std::string name() const override;