summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-14 10:16:39 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-14 10:16:39 +0200
commit444f09343e82e2aa209d0454f51f3b0d07bb1abc (patch)
tree89bd8c61880fba9aef76b6eef898c12bd2f0ee1c
parent111dbe139333a0fa697d7621414f1785b078468b (diff)
downloadcryptodev-linux-444f09343e82e2aa209d0454f51f3b0d07bb1abc.tar.gz
cryptodev-linux-444f09343e82e2aa209d0454f51f3b0d07bb1abc.tar.xz
cryptodev-linux-444f09343e82e2aa209d0454f51f3b0d07bb1abc.zip
Separated PK operations.
-rw-r--r--ncr-pk.h48
-rw-r--r--ncr_int.h44
2 files changed, 49 insertions, 43 deletions
diff --git a/ncr-pk.h b/ncr-pk.h
new file mode 100644
index 0000000..1180017
--- /dev/null
+++ b/ncr-pk.h
@@ -0,0 +1,48 @@
+#ifndef NCR_PK_H
+# define NCR_PK_H
+
+#include <tomcrypt.h>
+
+struct ncr_pk_ctx {
+ ncr_algorithm_t algorithm; /* algorithm */
+
+ ncr_algorithm_t sign_hash; /* for verification */
+
+ ncr_algorithm_t oaep_hash;
+ int salt_len; /* for RSA-PSS signatures */
+
+ int type; /* libtomcrypt type */
+ int init; /* non zero if initialized */
+
+ struct key_item_st * key;
+};
+
+/* PK */
+void ncr_pk_clear(struct key_item_st* key);
+int ncr_pk_generate(ncr_algorithm_t algo,
+ struct ncr_key_generate_params_st * params,
+ struct key_item_st* private, struct key_item_st* public);
+int ncr_pk_pack( const struct key_item_st * key, uint8_t * packed, uint32_t * packed_size);
+int ncr_pk_unpack( struct key_item_st * key, const void * packed, size_t packed_size);
+
+
+int ncr_pk_queue_init(void);
+void ncr_pk_queue_deinit(void);
+
+/* encryption/decryption */
+int ncr_pk_cipher_init(ncr_algorithm_t algo,
+ struct ncr_pk_ctx* ctx, struct ncr_key_params_st* params,
+ struct key_item_st *key);
+void ncr_pk_cipher_deinit(struct ncr_pk_ctx* ctx);
+int ncr_pk_cipher_encrypt(const struct ncr_pk_ctx* ctx, const void* input,
+ size_t input_size, void* output, size_t *output_size);
+int ncr_pk_cipher_decrypt(const struct ncr_pk_ctx* ctx, const void* input,
+ size_t input_size, void* output, size_t *output_size);
+int ncr_pk_cipher_sign(const struct ncr_pk_ctx* ctx, const void* input,
+ size_t input_size, void* output, size_t *output_size);
+
+int ncr_pk_cipher_verify(const struct ncr_pk_ctx* ctx,
+ const void* signature, size_t signature_size,
+ const void* hash, size_t hash_size, ncr_error_t*);
+
+#endif
diff --git a/ncr_int.h b/ncr_int.h
index 293e833..111f23c 100644
--- a/ncr_int.h
+++ b/ncr_int.h
@@ -4,26 +4,12 @@
#include "ncr.h"
#include <asm/atomic.h>
#include "cryptodev_int.h"
-#include <tomcrypt.h>
+#include <ncr-pk.h>
#define KEY_DATA_MAX_SIZE 3*1024
#define err() printk(KERN_DEBUG"ncr: %s: %s: %d\n", __FILE__, __func__, __LINE__)
-struct ncr_pk_ctx {
- ncr_algorithm_t algorithm; /* algorithm */
-
- ncr_algorithm_t sign_hash; /* for verification */
-
- ncr_algorithm_t oaep_hash;
- int salt_len; /* for RSA-PSS signatures */
-
- int type; /* libtomcrypt type */
- int init; /* non zero if initialized */
-
- struct key_item_st * key;
-};
-
struct session_item_st {
struct list_head list;
@@ -208,34 +194,6 @@ inline static unsigned int data_flags_to_key(unsigned int data_flags)
const char* _ncr_algo_to_str(ncr_algorithm_t algo);
int _ncr_algo_digest_size(ncr_algorithm_t algo);
-/* PK */
-void ncr_pk_clear(struct key_item_st* key);
-int ncr_pk_generate(ncr_algorithm_t algo,
- struct ncr_key_generate_params_st * params,
- struct key_item_st* private, struct key_item_st* public);
-int ncr_pk_pack( const struct key_item_st * key, uint8_t * packed, uint32_t * packed_size);
-int ncr_pk_unpack( struct key_item_st * key, const void * packed, size_t packed_size);
-
-
-int ncr_pk_queue_init(void);
-void ncr_pk_queue_deinit(void);
-
-/* encryption/decryption */
-int ncr_pk_cipher_init(ncr_algorithm_t algo,
- struct ncr_pk_ctx* ctx, struct ncr_key_params_st* params,
- struct key_item_st *key);
-void ncr_pk_cipher_deinit(struct ncr_pk_ctx* ctx);
-int ncr_pk_cipher_encrypt(const struct ncr_pk_ctx* ctx, const void* input,
- size_t input_size, void* output, size_t *output_size);
-int ncr_pk_cipher_decrypt(const struct ncr_pk_ctx* ctx, const void* input,
- size_t input_size, void* output, size_t *output_size);
-int ncr_pk_cipher_sign(const struct ncr_pk_ctx* ctx, const void* input,
- size_t input_size, void* output, size_t *output_size);
-
-int ncr_pk_cipher_verify(const struct ncr_pk_ctx* ctx,
- const void* signature, size_t signature_size,
- const void* hash, size_t hash_size, ncr_error_t*);
-
#endif