- began to implement aes_crypter_t
authorJan Hutter <jhutter@hsr.ch>
Fri, 25 Nov 2005 16:57:20 +0000 (16:57 -0000)
committerJan Hutter <jhutter@hsr.ch>
Fri, 25 Nov 2005 16:57:20 +0000 (16:57 -0000)
Source/charon/transforms/crypters/Makefile.crypters
Source/charon/transforms/crypters/aes_crypter.c [new file with mode: 0644]
Source/charon/transforms/crypters/aes_crypter.h [new file with mode: 0644]

index e4ce023..8260c23 100644 (file)
@@ -17,3 +17,7 @@ CRYPTERS_DIR= $(TRANSFORMS_DIR)crypters/
 OBJS+= $(BUILD_DIR)crypter.o
 $(BUILD_DIR)crypter.o :                        $(CRYPTERS_DIR)crypter.c $(CRYPTERS_DIR)crypter.h
                                                                $(CC) $(CFLAGS) -c -o $@ $<
+                                                               
+OBJS+= $(BUILD_DIR)aes_crypter.o
+$(BUILD_DIR)aes_crypter.o :            $(CRYPTERS_DIR)aes_crypter.c $(CRYPTERS_DIR)aes_crypter.h
+                                                               $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/Source/charon/transforms/crypters/aes_crypter.c b/Source/charon/transforms/crypters/aes_crypter.c
new file mode 100644 (file)
index 0000000..a97da07
--- /dev/null
@@ -0,0 +1,90 @@
+/**
+ * @file aes_crypter.c
+ * 
+ * @brief Implementation of aes_crypter_t
+ * 
+ */
+#include "aes_crypter.h"
+
+#include <utils/allocator.h>
+
+
+typedef struct private_aes_crypter_t private_aes_crypter_t;
+
+/**
+ * @brief Class implementing the AES symmetric encryption algorithm.
+ * 
+ * @ingroup crypters
+ */
+struct private_aes_crypter_t {
+       
+       /**
+        * Public part of this class
+        */
+       aes_crypter_t public;
+       
+};
+
+/**
+ * Implementation of crypter_t.encrypt.
+ */
+static status_t encrypt (private_aes_crypter_t *this, chunk_t data, chunk_t *encrypted)
+{
+       return SUCCESS;
+}
+
+/**
+ * Implementation of crypter_t.decrypt.
+ */
+static status_t decrypt (private_aes_crypter_t *this, chunk_t data, chunk_t *decrypted)
+{
+       return SUCCESS;
+}
+
+/**
+ * Implementation of crypter_t.get_block_size.
+ */
+static size_t get_block_size (private_aes_crypter_t *this)
+{
+       return SUCCESS;
+}
+
+/**
+ * Implementation of crypter_t.set_key.
+ */
+static status_t set_key (private_aes_crypter_t *this, chunk_t key)
+{
+       return SUCCESS;
+}
+
+/**
+ * Implementation of crypter_t.destroy and aes_crypter_t.destroy.
+ */
+static status_t destroy (private_aes_crypter_t *this)
+{
+       return SUCCESS;
+}
+
+
+aes_crypter_t *aes_crypter_create()
+{
+       private_aes_crypter_t *this = allocator_alloc_thing(private_aes_crypter_t);
+       if (this == NULL)
+       {
+               return NULL;    
+       }
+
+       /* functions of crypter_t interface */  
+       this->public.crypter_interface.encrypt = (status_t (*) (crypter_t *, chunk_t , chunk_t *)) encrypt;
+       this->public.crypter_interface.decrypt = (status_t (*) (crypter_t *, chunk_t , chunk_t *)) decrypt;
+       this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
+       this->public.crypter_interface.set_key = (status_t (*) (crypter_t *,chunk_t)) set_key;
+       this->public.crypter_interface.destroy = (status_t (*) (crypter_t *)) destroy;
+
+       /* public functions */
+       this->public.destroy = (status_t (*) (aes_crypter_t *)) destroy;
+       
+       
+       return &(this->public);
+}
diff --git a/Source/charon/transforms/crypters/aes_crypter.h b/Source/charon/transforms/crypters/aes_crypter.h
new file mode 100644 (file)
index 0000000..5889465
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * @file aes_crypter.h
+ * 
+ * @brief Interface of aes_crypter_t
+ * 
+ */
+
+
+#ifndef _AES_CRYPTER_H_
+#define _AES_CRYPTER_H_
+
+#include <transforms/crypters/crypter.h>
+
+
+typedef struct aes_crypter_t aes_crypter_t;
+
+/**
+ * @brief Class implementing the AES symmetric encryption algorithm.
+ * 
+ * @ingroup crypters
+ */
+struct aes_crypter_t {
+       
+       /**
+        * crypter_t interface.
+        */
+       crypter_t crypter_interface;
+       
+       /**
+        * @brief Destroys a aes_crypter_t object.
+        *
+        * @param this                          crypter_t object to destroy
+        * @return              
+        *                                                      - SUCCESS in any case
+        */
+       status_t (*destroy) (aes_crypter_t *this);
+};
+
+/**
+ * @brief Constructor to create aes_crypter_t objects.
+ * 
+ * @return
+ *                                                             - aes_crypter_t if successfully
+ *                                                             - NULL if out of ressources
+ */
+aes_crypter_t *aes_crypter_create();
+
+
+
+#endif //_AES_CRYPTER_H_