aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/padlock
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/padlock')
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_aes_crypter.c28
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_aes_crypter.h4
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_plugin.c12
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_rng.c18
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_rng.h2
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_sha1_hasher.c22
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_sha1_hasher.h2
7 files changed, 44 insertions, 44 deletions
diff --git a/src/libstrongswan/plugins/padlock/padlock_aes_crypter.c b/src/libstrongswan/plugins/padlock/padlock_aes_crypter.c
index afdd85b79..9edea4bd3 100644
--- a/src/libstrongswan/plugins/padlock/padlock_aes_crypter.c
+++ b/src/libstrongswan/plugins/padlock/padlock_aes_crypter.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2008 Thomas Kallenberg
* Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -26,12 +26,12 @@ typedef struct private_padlock_aes_crypter_t private_padlock_aes_crypter_t;
* Private data of padlock_aes_crypter_t
*/
struct private_padlock_aes_crypter_t {
-
+
/**
* Public part of this class.
*/
padlock_aes_crypter_t public;
-
+
/*
* the key
*/
@@ -56,7 +56,7 @@ typedef struct {
/**
* Invoke the actual de/encryption
*/
-static void padlock_crypt(void *key, void *ctrl, void *src, void *dst,
+static void padlock_crypt(void *key, void *ctrl, void *src, void *dst,
int count, void *iv)
{
asm volatile(
@@ -81,7 +81,7 @@ static void padlock_crypt(void *key, void *ctrl, void *src, void *dst,
/*
* Implementation of crypter_t.crypt
*/
-static void crypt(private_padlock_aes_crypter_t *this, char *iv,
+static void crypt(private_padlock_aes_crypter_t *this, char *iv,
chunk_t src, chunk_t *dst, bool enc)
{
cword cword PADLOCK_ALIGN;
@@ -110,7 +110,7 @@ static void crypt(private_padlock_aes_crypter_t *this, char *iv,
/**
* Implementation of crypter_t.decrypt.
*/
-static void decrypt(private_padlock_aes_crypter_t *this, chunk_t data,
+static void decrypt(private_padlock_aes_crypter_t *this, chunk_t data,
chunk_t iv, chunk_t *dst)
{
crypt(this, iv.ptr, data, dst, TRUE);
@@ -120,7 +120,7 @@ static void decrypt(private_padlock_aes_crypter_t *this, chunk_t data,
/**
* Implementation of crypter_t.encrypt.
*/
-static void encrypt (private_padlock_aes_crypter_t *this, chunk_t data,
+static void encrypt (private_padlock_aes_crypter_t *this, chunk_t data,
chunk_t iv, chunk_t *dst)
{
crypt(this, iv.ptr, data, dst, FALSE);
@@ -162,18 +162,18 @@ static void destroy (private_padlock_aes_crypter_t *this)
/*
* Described in header
*/
-padlock_aes_crypter_t *padlock_aes_crypter_create(encryption_algorithm_t algo,
+padlock_aes_crypter_t *padlock_aes_crypter_create(encryption_algorithm_t algo,
size_t key_size)
{
private_padlock_aes_crypter_t *this;
-
+
if (algo != ENCR_AES_CBC)
{
return NULL;
}
-
+
this = malloc_thing(private_padlock_aes_crypter_t);
-
+
switch (key_size)
{
case 16: /* AES 128 */
@@ -185,15 +185,15 @@ padlock_aes_crypter_t *padlock_aes_crypter_create(encryption_algorithm_t algo,
free(this);
return NULL;
}
-
+
this->key = chunk_alloc(key_size);
-
+
this->public.crypter_interface.encrypt = (void (*) (crypter_t *, chunk_t,chunk_t, chunk_t *)) encrypt;
this->public.crypter_interface.decrypt = (void (*) (crypter_t *, chunk_t , chunk_t, chunk_t *)) decrypt;
this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
this->public.crypter_interface.set_key = (void (*) (crypter_t *,chunk_t)) set_key;
this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-
+
return &this->public;
}
diff --git a/src/libstrongswan/plugins/padlock/padlock_aes_crypter.h b/src/libstrongswan/plugins/padlock/padlock_aes_crypter.h
index d8ac9c2a0..d4c7a7577 100644
--- a/src/libstrongswan/plugins/padlock/padlock_aes_crypter.h
+++ b/src/libstrongswan/plugins/padlock/padlock_aes_crypter.h
@@ -30,7 +30,7 @@ typedef struct padlock_aes_crypter_t padlock_aes_crypter_t;
* Implementation of AES-128 using VIA Padlock.
*/
struct padlock_aes_crypter_t {
-
+
/**
* The crypter_t interface.
*/
@@ -39,7 +39,7 @@ struct padlock_aes_crypter_t {
/**
* Constructor to create padlock_aes_crypter_t.
- *
+ *
* @param key_size key size in bytes, currently supports only 16.
* @param algo algorithm to implement, must be ENCR_AES_CBC
* @return padlock_aes_crypter_t, NULL if not supported
diff --git a/src/libstrongswan/plugins/padlock/padlock_plugin.c b/src/libstrongswan/plugins/padlock/padlock_plugin.c
index e241b59be..32b18ec4b 100644
--- a/src/libstrongswan/plugins/padlock/padlock_plugin.c
+++ b/src/libstrongswan/plugins/padlock/padlock_plugin.c
@@ -55,7 +55,7 @@ struct private_padlock_plugin_t {
* public functions
*/
padlock_plugin_t public;
-
+
/**
* features supported by Padlock
*/
@@ -81,11 +81,11 @@ static padlock_feature_t get_padlock_features()
{
char vendor[3 * sizeof(int) + 1];
int a, b, c, d;
-
+
cpuid(0, a, b, c, d);
/* VendorID string is in b-d-c (yes, in this order) */
snprintf(vendor, sizeof(vendor), "%.4s%.4s%.4s", &b, &d, &c);
-
+
/* check if we have a VIA chip */
if (streq(vendor, "CentaurHauls"))
{
@@ -134,9 +134,9 @@ static void destroy(private_padlock_plugin_t *this)
plugin_t *plugin_create()
{
private_padlock_plugin_t *this = malloc_thing(private_padlock_plugin_t);
-
+
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-
+
this->features = get_padlock_features();
if (!this->features)
{
@@ -154,7 +154,7 @@ plugin_t *plugin_create()
this->features & PADLOCK_ACE2_ENABLED ? " ACE2" : "",
this->features & PADLOCK_PHE_ENABLED ? " PHE" : "",
this->features & PADLOCK_PMM_ENABLED ? " PMM" : "");
-
+
if (this->features & PADLOCK_RNG_ENABLED)
{
lib->crypto->add_rng(lib->crypto, RNG_TRUE,
diff --git a/src/libstrongswan/plugins/padlock/padlock_rng.c b/src/libstrongswan/plugins/padlock/padlock_rng.c
index 8a04dccfc..8ff46081b 100644
--- a/src/libstrongswan/plugins/padlock/padlock_rng.c
+++ b/src/libstrongswan/plugins/padlock/padlock_rng.c
@@ -36,12 +36,12 @@ enum padlock_quality_factor_t {
* Private data of an padlock_rng_t object.
*/
struct private_padlock_rng_t {
-
+
/**
* Public padlock_rng_t interface.
*/
padlock_rng_t public;
-
+
/**
* Padlock quality factor
*/
@@ -56,14 +56,14 @@ static void rng(char *buf, int len, int quality)
while (len > 0)
{
int status;
-
+
/* run XSTORE until we have all bytes needed. We do not use REP, as
* this should not be performance critical and it's easier this way. */
asm volatile (
".byte 0x0F,0xA7,0xC0 \n\t"
: "=D"(buf), "=a"(status)
: "d"(quality), "D"(buf));
-
+
/* bits[0..4] of status word contains the number of bytes read */
len -= status & 0x1F;
}
@@ -78,7 +78,7 @@ static void allocate_bytes(private_padlock_rng_t *this, size_t bytes,
chunk->len = bytes;
/* padlock requires some additional bytes */
chunk->ptr = malloc(bytes + 7);
-
+
rng(chunk->ptr, chunk->len, this->quality);
}
@@ -89,7 +89,7 @@ static void get_bytes(private_padlock_rng_t *this, size_t bytes,
u_int8_t *buffer)
{
chunk_t chunk;
-
+
/* Padlock needs a larger buffer than "bytes", we need a new buffer */
allocate_bytes(this, bytes, &chunk);
memcpy(buffer, chunk.ptr, bytes);
@@ -110,11 +110,11 @@ static void destroy(private_padlock_rng_t *this)
padlock_rng_t *padlock_rng_create(rng_quality_t quality)
{
private_padlock_rng_t *this = malloc_thing(private_padlock_rng_t);
-
+
this->public.rng.get_bytes = (void (*) (rng_t *, size_t, u_int8_t*)) get_bytes;
this->public.rng.allocate_bytes = (void (*) (rng_t *, size_t, chunk_t*)) allocate_bytes;
this->public.rng.destroy = (void (*) (rng_t *))destroy;
-
+
/* map RNG quality to Padlock quality factor */
switch (quality)
{
@@ -128,7 +128,7 @@ padlock_rng_t *padlock_rng_create(rng_quality_t quality)
this->quality = PADLOCK_QF3;
break;
}
-
+
return &this->public;
}
diff --git a/src/libstrongswan/plugins/padlock/padlock_rng.h b/src/libstrongswan/plugins/padlock/padlock_rng.h
index 237d8fbe2..7fb9a89d5 100644
--- a/src/libstrongswan/plugins/padlock/padlock_rng.h
+++ b/src/libstrongswan/plugins/padlock/padlock_rng.h
@@ -29,7 +29,7 @@ typedef struct padlock_rng_t padlock_rng_t;
* Hardware-RNG based on via Padlock.
*/
struct padlock_rng_t {
-
+
/**
* Implements rng_t interface.
*/
diff --git a/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.c b/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.c
index b5a6abc64..30c2a8617 100644
--- a/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.c
+++ b/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.c
@@ -32,7 +32,7 @@ struct private_padlock_sha1_hasher_t {
* Public interface for this hasher.
*/
padlock_sha1_hasher_t public;
-
+
/**
* data collected to hash
*/
@@ -46,7 +46,7 @@ static void padlock_sha1(int len, u_char *in, u_char *out)
{
/* rep xsha1 */
asm volatile (
- ".byte 0xf3, 0x0f, 0xa6, 0xc8"
+ ".byte 0xf3, 0x0f, 0xa6, 0xc8"
: "+S"(in), "+D"(out)
: "c"(len), "a"(0));
}
@@ -57,7 +57,7 @@ static void padlock_sha1(int len, u_char *in, u_char *out)
static void sha1(chunk_t data, u_int32_t *digest)
{
u_int32_t hash[128] PADLOCK_ALIGN;
-
+
hash[0] = 0x67452301;
hash[1] = 0xefcdab89;
hash[2] = 0x98badcfe;
@@ -105,14 +105,14 @@ static void get_hash(private_padlock_sha1_hasher_t *this, chunk_t chunk,
sha1(this->data, (u_int32_t*)hash);
}
else
- { /* hash directly if no previous data found */
+ { /* hash directly if no previous data found */
sha1(chunk, (u_int32_t*)hash);
}
reset(this);
}
else
{
- append_data(this, chunk);
+ append_data(this, chunk);
}
}
@@ -129,10 +129,10 @@ static void allocate_hash(private_padlock_sha1_hasher_t *this, chunk_t chunk,
}
else
{
- get_hash(this, chunk, NULL);
+ get_hash(this, chunk, NULL);
}
}
-
+
/**
* Implementation of hasher_t.get_hash_size.
*/
@@ -156,20 +156,20 @@ static void destroy(private_padlock_sha1_hasher_t *this)
padlock_sha1_hasher_t *padlock_sha1_hasher_create(hash_algorithm_t algo)
{
private_padlock_sha1_hasher_t *this;
-
+
if (algo != HASH_SHA1)
{
return NULL;
}
-
+
this = malloc_thing(private_padlock_sha1_hasher_t);
this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-
+
this->data = chunk_empty;
-
+
return &(this->public);
}
diff --git a/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.h b/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.h
index afa1e046d..740bdfe98 100644
--- a/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.h
+++ b/src/libstrongswan/plugins/padlock/padlock_sha1_hasher.h
@@ -30,7 +30,7 @@ typedef struct padlock_sha1_hasher_t padlock_sha1_hasher_t;
* Implementation of hasher_t interface using the SHA1 algorithm.
*/
struct padlock_sha1_hasher_t {
-
+
/**
* Implements hasher_t interface.
*/