removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_crypter.h"
|
||||
|
||||
/*
|
||||
@@ -36,26 +36,26 @@ typedef struct private_aes_crypter_t private_aes_crypter_t;
|
||||
|
||||
/**
|
||||
* Class implementing the AES symmetric encryption algorithm.
|
||||
*
|
||||
*
|
||||
* @ingroup crypters
|
||||
*/
|
||||
struct private_aes_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
aes_crypter_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Number of words in the key input block.
|
||||
*/
|
||||
u_int32_t aes_Nkey;
|
||||
|
||||
|
||||
/**
|
||||
* The number of cipher rounds.
|
||||
*/
|
||||
u_int32_t aes_Nrnd;
|
||||
|
||||
|
||||
/**
|
||||
* The encryption key schedule.
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ struct private_aes_crypter_t {
|
||||
* The decryption key schedule.
|
||||
*/
|
||||
u_int32_t aes_d_key[AES_KS_LENGTH];
|
||||
|
||||
|
||||
/**
|
||||
* Key size of this AES cypher object.
|
||||
*/
|
||||
@@ -84,13 +84,13 @@ struct private_aes_crypter_t {
|
||||
* is not defined, individually declared 32-bit words are used.
|
||||
* 6. Define FAST_VARIABLE if a high speed variable block implementation
|
||||
* is needed (essentially three separate fixed block size code sequences)
|
||||
* 7. Define either ONE_TABLE or FOUR_TABLES for a fast table driven
|
||||
* 7. Define either ONE_TABLE or FOUR_TABLES for a fast table driven
|
||||
* version using 1 table (2 kbytes of table space) or 4 tables (8
|
||||
* kbytes of table space) for higher speed.
|
||||
* 8. Define either ONE_LR_TABLE or FOUR_LR_TABLES for a further speed
|
||||
* 8. Define either ONE_LR_TABLE or FOUR_LR_TABLES for a further speed
|
||||
* increase by using tables for the last rounds but with more table
|
||||
* space (2 or 8 kbytes extra).
|
||||
* 9. If neither ONE_TABLE nor FOUR_TABLES is defined, a compact but
|
||||
* 9. If neither ONE_TABLE nor FOUR_TABLES is defined, a compact but
|
||||
* slower version is provided.
|
||||
* 10. If fast decryption key scheduling is needed define ONE_IM_TABLE
|
||||
* or FOUR_IM_TABLES for higher speed (2 or 8 kbytes extra).
|
||||
@@ -131,17 +131,17 @@ struct private_aes_crypter_t {
|
||||
|
||||
#if defined(AES_BLOCK_SIZE) && AES_BLOCK_SIZE != 16 && AES_BLOCK_SIZE != 24 && AES_BLOCK_SIZE != 32
|
||||
#error an illegal block size has been specified
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Rotates bytes within words by n positions, moving bytes
|
||||
* Rotates bytes within words by n positions, moving bytes
|
||||
* to higher index positions with wrap around into low positions.
|
||||
*/
|
||||
*/
|
||||
#define upr(x,n) (((x) << 8 * (n)) | ((x) >> (32 - 8 * (n))))
|
||||
/**
|
||||
* Moves bytes by n positions to higher index positions in
|
||||
* Moves bytes by n positions to higher index positions in
|
||||
* words but without wrap around.
|
||||
*/
|
||||
*/
|
||||
#define ups(x,n) ((x) << 8 * (n))
|
||||
|
||||
/**
|
||||
@@ -154,7 +154,7 @@ struct private_aes_crypter_t {
|
||||
|
||||
/* little endian processor without data alignment restrictions: AES_LE_OK */
|
||||
/* original code: i386 */
|
||||
#if defined(i386) || defined(_I386) || defined(__i386__) || defined(__i386)
|
||||
#if defined(i386) || defined(_I386) || defined(__i386__) || defined(__i386)
|
||||
#define AES_LE_OK 1
|
||||
/* added (tested): alpha --jjo */
|
||||
#elif defined(__alpha__)|| defined (__alpha)
|
||||
@@ -220,9 +220,9 @@ struct private_aes_crypter_t {
|
||||
// give improved performance if a fast 32-bit multiply is not available. Note
|
||||
// that a temporary variable u needs to be defined where FFmulX is used.
|
||||
|
||||
// #define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
|
||||
// #define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
|
||||
// #define m4 0x1b1b1b1b
|
||||
// #define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
|
||||
// #define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
|
||||
|
||||
// perform column mix operation on four bytes in parallel
|
||||
|
||||
@@ -343,7 +343,7 @@ static const u_int32_t rcon_tab[29] =
|
||||
#define w2(p) 0x00##p##0000
|
||||
#define w3(p) 0x##p##000000
|
||||
|
||||
#if defined(FIXED_TABLES) && (defined(ONE_TABLE) || defined(FOUR_TABLES))
|
||||
#if defined(FIXED_TABLES) && (defined(ONE_TABLE) || defined(FOUR_TABLES))
|
||||
|
||||
// data for forward tables (other than last round)
|
||||
|
||||
@@ -526,7 +526,7 @@ static const u_int32_t it_tab[4][256] =
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FIXED_TABLES) && (defined(ONE_LR_TABLE) || defined(FOUR_LR_TABLES))
|
||||
#if defined(FIXED_TABLES) && (defined(ONE_LR_TABLE) || defined(FOUR_LR_TABLES))
|
||||
|
||||
// data for inverse tables (last round)
|
||||
|
||||
@@ -608,7 +608,7 @@ static const u_int32_t il_tab[4][256] =
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FIXED_TABLES) && (defined(ONE_IM_TABLE) || defined(FOUR_IM_TABLES))
|
||||
#if defined(FIXED_TABLES) && (defined(ONE_IM_TABLE) || defined(FOUR_IM_TABLES))
|
||||
|
||||
#define m_table \
|
||||
r(00,00,00,00), r(0b,0d,09,0e), r(16,1a,12,1c), r(1d,17,1b,12),\
|
||||
@@ -733,8 +733,8 @@ static u_int32_t im_tab[4][256];
|
||||
|
||||
#if !defined(FF_TABLES)
|
||||
|
||||
// It will generally be sensible to use tables to compute finite
|
||||
// field multiplies and inverses but where memory is scarse this
|
||||
// It will generally be sensible to use tables to compute finite
|
||||
// field multiplies and inverses but where memory is scarse this
|
||||
// code might sometimes be better.
|
||||
|
||||
// return 2 ^ (n - 1) where n is the bit number of the highest bit
|
||||
@@ -743,7 +743,7 @@ static u_int32_t im_tab[4][256];
|
||||
|
||||
static unsigned char hibit(const u_int32_t x)
|
||||
{ unsigned char r = (unsigned char)((x >> 1) | (x >> 2));
|
||||
|
||||
|
||||
r |= (r >> 2);
|
||||
r |= (r >> 4);
|
||||
return (r + 1) >> 1;
|
||||
@@ -761,14 +761,14 @@ static unsigned char FFinv(const unsigned char x)
|
||||
if(!n1) return v1;
|
||||
|
||||
while(n2 >= n1)
|
||||
{
|
||||
{
|
||||
n2 /= n1; p2 ^= p1 * n2; v2 ^= v1 * n2; n2 = hibit(p2);
|
||||
}
|
||||
|
||||
|
||||
if(!n2) return v2;
|
||||
|
||||
while(n1 >= n2)
|
||||
{
|
||||
{
|
||||
n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1);
|
||||
}
|
||||
}
|
||||
@@ -815,9 +815,9 @@ static void gen_tabs(void)
|
||||
// 0x011b as modular polynomial - the simplest primitive
|
||||
// root is 0x03, used here to generate the tables
|
||||
|
||||
i = 0; w = 1;
|
||||
i = 0; w = 1;
|
||||
do
|
||||
{
|
||||
{
|
||||
pow[i] = (unsigned char)w;
|
||||
pow[i + 255] = (unsigned char)w;
|
||||
log[w] = (unsigned char)i++;
|
||||
@@ -987,8 +987,8 @@ switch(nc) \
|
||||
// is being computed, return the input state variables which are
|
||||
// needed for each row (r) of the state
|
||||
|
||||
// For the fixed block size options, compilers reduce these two
|
||||
// expressions to fixed variable references. For variable block
|
||||
// For the fixed block size options, compilers reduce these two
|
||||
// expressions to fixed variable references. For variable block
|
||||
// size code conditional clauses will sometimes be returned
|
||||
|
||||
#define unused 77 // Sunset Strip
|
||||
@@ -1226,17 +1226,17 @@ static void encrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
|
||||
switch(this->aes_Nrnd)
|
||||
{
|
||||
case 14: round(fwd_rnd, b1, b0, kp );
|
||||
case 14: round(fwd_rnd, b1, b0, kp );
|
||||
round(fwd_rnd, b0, b1, kp + nc ); kp += 2 * nc;
|
||||
case 12: round(fwd_rnd, b1, b0, kp );
|
||||
case 12: round(fwd_rnd, b1, b0, kp );
|
||||
round(fwd_rnd, b0, b1, kp + nc ); kp += 2 * nc;
|
||||
case 10: round(fwd_rnd, b1, b0, kp );
|
||||
case 10: round(fwd_rnd, b1, b0, kp );
|
||||
round(fwd_rnd, b0, b1, kp + nc);
|
||||
round(fwd_rnd, b1, b0, kp + 2 * nc);
|
||||
round(fwd_rnd, b1, b0, kp + 2 * nc);
|
||||
round(fwd_rnd, b0, b1, kp + 3 * nc);
|
||||
round(fwd_rnd, b1, b0, kp + 4 * nc);
|
||||
round(fwd_rnd, b1, b0, kp + 4 * nc);
|
||||
round(fwd_rnd, b0, b1, kp + 5 * nc);
|
||||
round(fwd_rnd, b1, b0, kp + 6 * nc);
|
||||
round(fwd_rnd, b1, b0, kp + 6 * nc);
|
||||
round(fwd_rnd, b0, b1, kp + 7 * nc);
|
||||
round(fwd_rnd, b1, b0, kp + 8 * nc);
|
||||
round(fwd_lrnd, b0, b1, kp + 9 * nc);
|
||||
@@ -1247,7 +1247,7 @@ static void encrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
|
||||
for(rnd = 0; rnd < (this->aes_Nrnd >> 1) - 1; ++rnd)
|
||||
{
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
round(fwd_rnd, b0, b1, kp + nc); kp += 2 * nc;
|
||||
}
|
||||
|
||||
@@ -1259,7 +1259,7 @@ static void encrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
|
||||
for(rnd = 0; rnd < this->aes_Nrnd - 1; ++rnd)
|
||||
{
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
l_copy(b0, b1); kp += nc;
|
||||
}
|
||||
|
||||
@@ -1278,7 +1278,7 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
const u_int32_t *kp = this->aes_d_key;
|
||||
|
||||
#if !defined(ONE_TABLE) && !defined(FOUR_TABLES)
|
||||
u_int32_t f2, f4, f8, f9;
|
||||
u_int32_t f2, f4, f8, f9;
|
||||
#endif
|
||||
|
||||
state_in(b0, in_blk, kp); kp += nc;
|
||||
@@ -1291,13 +1291,13 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
round(inv_rnd, b0, b1, kp + nc ); kp += 2 * nc;
|
||||
case 12: round(inv_rnd, b1, b0, kp );
|
||||
round(inv_rnd, b0, b1, kp + nc ); kp += 2 * nc;
|
||||
case 10: round(inv_rnd, b1, b0, kp );
|
||||
case 10: round(inv_rnd, b1, b0, kp );
|
||||
round(inv_rnd, b0, b1, kp + nc);
|
||||
round(inv_rnd, b1, b0, kp + 2 * nc);
|
||||
round(inv_rnd, b1, b0, kp + 2 * nc);
|
||||
round(inv_rnd, b0, b1, kp + 3 * nc);
|
||||
round(inv_rnd, b1, b0, kp + 4 * nc);
|
||||
round(inv_rnd, b1, b0, kp + 4 * nc);
|
||||
round(inv_rnd, b0, b1, kp + 5 * nc);
|
||||
round(inv_rnd, b1, b0, kp + 6 * nc);
|
||||
round(inv_rnd, b1, b0, kp + 6 * nc);
|
||||
round(inv_rnd, b0, b1, kp + 7 * nc);
|
||||
round(inv_rnd, b1, b0, kp + 8 * nc);
|
||||
round(inv_lrnd, b0, b1, kp + 9 * nc);
|
||||
@@ -1308,7 +1308,7 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
|
||||
for(rnd = 0; rnd < (this->aes_Nrnd >> 1) - 1; ++rnd)
|
||||
{
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
round(inv_rnd, b0, b1, kp + nc); kp += 2 * nc;
|
||||
}
|
||||
|
||||
@@ -1320,7 +1320,7 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
|
||||
|
||||
for(rnd = 0; rnd < this->aes_Nrnd - 1; ++rnd)
|
||||
{
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
l_copy(b0, b1); kp += nc;
|
||||
}
|
||||
|
||||
@@ -1340,7 +1340,7 @@ static void decrypt(private_aes_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
int pos;
|
||||
const u_int32_t *iv_i;
|
||||
u_int8_t *in, *out;
|
||||
|
||||
|
||||
if (decrypted)
|
||||
{
|
||||
*decrypted = chunk_alloc(data.len);
|
||||
@@ -1351,7 +1351,7 @@ static void decrypt(private_aes_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
out = data.ptr;
|
||||
}
|
||||
in = data.ptr;
|
||||
|
||||
|
||||
pos = data.len-16;
|
||||
in += pos;
|
||||
out += pos;
|
||||
@@ -1386,7 +1386,7 @@ static void encrypt (private_aes_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
int pos;
|
||||
const u_int32_t *iv_i;
|
||||
u_int8_t *in, *out;
|
||||
|
||||
|
||||
in = data.ptr;
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
@@ -1394,7 +1394,7 @@ static void encrypt (private_aes_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
*encrypted = chunk_alloc(data.len);
|
||||
out = encrypted->ptr;
|
||||
}
|
||||
|
||||
|
||||
pos=0;
|
||||
while(pos<data.len)
|
||||
{
|
||||
@@ -1440,18 +1440,18 @@ static void set_key (private_aes_crypter_t *this, chunk_t key)
|
||||
{
|
||||
u_int32_t *kf, *kt, rci, f = 0;
|
||||
u_int8_t *in_key = key.ptr;
|
||||
|
||||
this->aes_Nrnd = (this->aes_Nkey > (nc) ? this->aes_Nkey : (nc)) + 6;
|
||||
|
||||
|
||||
this->aes_Nrnd = (this->aes_Nkey > (nc) ? this->aes_Nkey : (nc)) + 6;
|
||||
|
||||
this->aes_e_key[0] = const_word_in(in_key );
|
||||
this->aes_e_key[1] = const_word_in(in_key + 4);
|
||||
this->aes_e_key[2] = const_word_in(in_key + 8);
|
||||
this->aes_e_key[3] = const_word_in(in_key + 12);
|
||||
|
||||
kf = this->aes_e_key;
|
||||
kt = kf + nc * (this->aes_Nrnd + 1) - this->aes_Nkey;
|
||||
|
||||
kf = this->aes_e_key;
|
||||
kt = kf + nc * (this->aes_Nrnd + 1) - this->aes_Nkey;
|
||||
rci = 0;
|
||||
|
||||
|
||||
switch(this->aes_Nkey)
|
||||
{
|
||||
case 4: do
|
||||
@@ -1463,7 +1463,7 @@ static void set_key (private_aes_crypter_t *this, chunk_t key)
|
||||
}
|
||||
while(kf < kt);
|
||||
break;
|
||||
|
||||
|
||||
case 6: this->aes_e_key[4] = const_word_in(in_key + 16);
|
||||
this->aes_e_key[5] = const_word_in(in_key + 20);
|
||||
do
|
||||
@@ -1496,18 +1496,18 @@ static void set_key (private_aes_crypter_t *this, chunk_t key)
|
||||
while (kf < kt);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(!f)
|
||||
{
|
||||
u_int32_t i;
|
||||
|
||||
kt = this->aes_d_key + nc * this->aes_Nrnd;
|
||||
kf = this->aes_e_key;
|
||||
|
||||
|
||||
cpy(kt, kf); kt -= 2 * nc;
|
||||
|
||||
|
||||
for(i = 1; i < this->aes_Nrnd; ++i)
|
||||
{
|
||||
{
|
||||
#if defined(ONE_TABLE) || defined(FOUR_TABLES)
|
||||
#if !defined(ONE_IM_TABLE) && !defined(FOUR_IM_TABLES)
|
||||
u_int32_t f2, f4, f8, f9;
|
||||
@@ -1536,18 +1536,18 @@ static void destroy (private_aes_crypter_t *this)
|
||||
aes_crypter_t *aes_crypter_create(encryption_algorithm_t algo, size_t key_size)
|
||||
{
|
||||
private_aes_crypter_t *this;
|
||||
|
||||
|
||||
if (algo != ENCR_AES_CBC)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_aes_crypter_t);
|
||||
|
||||
|
||||
#if !defined(FIXED_TABLES)
|
||||
if(!tab_gen) { gen_tabs(); tab_gen = 1; }
|
||||
#endif
|
||||
|
||||
|
||||
this->key_size = key_size;
|
||||
switch(key_size)
|
||||
{
|
||||
@@ -1564,13 +1564,13 @@ aes_crypter_t *aes_crypter_create(encryption_algorithm_t algo, size_t key_size)
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct aes_crypter_t aes_crypter_t;
|
||||
* Class implementing the AES encryption algorithm.
|
||||
*/
|
||||
struct aes_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* The crypter_t interface.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ struct aes_crypter_t {
|
||||
|
||||
/**
|
||||
* Constructor to create aes_crypter_t objects.
|
||||
*
|
||||
*
|
||||
* @param key_size key size in bytes
|
||||
* @param algo algorithm to implement
|
||||
* @return aes_crypter_t object, NULL if not supported
|
||||
|
||||
@@ -47,12 +47,12 @@ static void destroy(private_aes_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_aes_plugin_t *this = malloc_thing(private_aes_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
|
||||
(crypter_constructor_t)aes_crypter_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ static void destroy(private_agent_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_agent_plugin_t *this = malloc_thing(private_agent_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
(builder_constructor_t)agent_private_key_builder);
|
||||
return &this->public.plugin;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* @defgroup agent_p agent
|
||||
* @ingroup plugins
|
||||
*
|
||||
*
|
||||
* @defgroup agent_plugin agent_plugin
|
||||
* @{ @ingroup agent_p
|
||||
*/
|
||||
|
||||
@@ -42,22 +42,22 @@ struct private_agent_private_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
agent_private_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* ssh-agent unix socket connection
|
||||
*/
|
||||
int socket;
|
||||
|
||||
|
||||
/**
|
||||
* key identity blob in ssh format
|
||||
*/
|
||||
chunk_t key;
|
||||
|
||||
|
||||
/**
|
||||
* keysize in bytes
|
||||
*/
|
||||
size_t key_size;
|
||||
|
||||
|
||||
/**
|
||||
* reference count
|
||||
*/
|
||||
@@ -115,7 +115,7 @@ static chunk_t read_string(chunk_t *blob)
|
||||
{
|
||||
int len;
|
||||
chunk_t str;
|
||||
|
||||
|
||||
len = read_uint32(blob);
|
||||
if (len > blob->len)
|
||||
{
|
||||
@@ -140,11 +140,11 @@ static int open_connection(char *path)
|
||||
DBG1("opening ssh-agent socket %s failed: %s:", path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
|
||||
strncpy(addr.sun_path, path, UNIX_PATH_MAX - 1);
|
||||
|
||||
|
||||
if (connect(s, (struct sockaddr*)&addr, SUN_LEN(&addr)) != 0)
|
||||
{
|
||||
DBG1("connecting to ssh-agent socket failed: %s", strerror(errno));
|
||||
@@ -154,7 +154,7 @@ static int open_connection(char *path)
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the first usable key from the agent
|
||||
*/
|
||||
static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
|
||||
@@ -162,7 +162,7 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
|
||||
int len, count;
|
||||
char buf[2048];
|
||||
chunk_t blob = chunk_from_buf(buf), key, type, n;
|
||||
|
||||
|
||||
len = htonl(1);
|
||||
buf[0] = SSH_AGENT_ID_REQUEST;
|
||||
if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
|
||||
@@ -171,9 +171,9 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
|
||||
DBG1("writing to ssh-agent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
blob.len = read(this->socket, blob.ptr, blob.len);
|
||||
|
||||
|
||||
if (blob.len < sizeof(u_int32_t) + sizeof(u_char) ||
|
||||
read_uint32(&blob) != blob.len ||
|
||||
read_byte(&blob) != SSH_AGENT_ID_RESPONSE)
|
||||
@@ -182,7 +182,7 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
|
||||
return FALSE;
|
||||
}
|
||||
count = read_uint32(&blob);
|
||||
|
||||
|
||||
while (blob.len)
|
||||
{
|
||||
key = read_string(&blob);
|
||||
@@ -221,20 +221,20 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
|
||||
/**
|
||||
* Implementation of agent_private_key.destroy.
|
||||
*/
|
||||
static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
|
||||
static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature)
|
||||
{
|
||||
u_int32_t len, flags;
|
||||
char buf[2048];
|
||||
chunk_t blob = chunk_from_buf(buf);
|
||||
|
||||
|
||||
if (scheme != SIGN_RSA_EMSA_PKCS1_SHA1)
|
||||
{
|
||||
DBG1("signature scheme %N not supported by ssh-agent",
|
||||
signature_scheme_names, scheme);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
len = htonl(1 + sizeof(u_int32_t) * 3 + this->key.len + data.len);
|
||||
buf[0] = SSH_AGENT_SIGN_REQUEST;
|
||||
if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
|
||||
@@ -243,7 +243,7 @@ static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
|
||||
DBG1("writing to ssh-agent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
len = htonl(this->key.len);
|
||||
if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
|
||||
write(this->socket, this->key.ptr, this->key.len) != this->key.len)
|
||||
@@ -251,7 +251,7 @@ static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
|
||||
DBG1("writing to ssh-agent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
len = htonl(data.len);
|
||||
if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
|
||||
write(this->socket, data.ptr, data.len) != data.len)
|
||||
@@ -259,14 +259,14 @@ static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
|
||||
DBG1("writing to ssh-agent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
flags = htonl(0);
|
||||
if (write(this->socket, &flags, sizeof(flags)) != sizeof(flags))
|
||||
{
|
||||
DBG1("writing to ssh-agent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
blob.len = read(this->socket, blob.ptr, blob.len);
|
||||
if (blob.len < sizeof(u_int32_t) + sizeof(u_char) ||
|
||||
read_uint32(&blob) != blob.len ||
|
||||
@@ -322,12 +322,12 @@ static size_t get_keysize(private_agent_private_key_t *this)
|
||||
static public_key_t* get_public_key(private_agent_private_key_t *this)
|
||||
{
|
||||
chunk_t key, n, e;
|
||||
|
||||
|
||||
key = this->key;
|
||||
read_string(&key);
|
||||
e = read_string(&key);
|
||||
n = read_string(&key);
|
||||
|
||||
|
||||
return lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
|
||||
}
|
||||
@@ -348,7 +348,7 @@ static bool get_fingerprint(private_agent_private_key_t *this,
|
||||
key_encoding_type_t type, chunk_t *fp)
|
||||
{
|
||||
chunk_t n, e, key;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, this, fp))
|
||||
{
|
||||
return TRUE;
|
||||
@@ -357,7 +357,7 @@ static bool get_fingerprint(private_agent_private_key_t *this,
|
||||
read_string(&key);
|
||||
e = read_string(&key);
|
||||
n = read_string(&key);
|
||||
|
||||
|
||||
return lib->encoding->encode(lib->encoding, type, this, fp,
|
||||
KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
|
||||
}
|
||||
@@ -392,7 +392,7 @@ static agent_private_key_t *agent_private_key_create(char *path,
|
||||
public_key_t *pubkey)
|
||||
{
|
||||
private_agent_private_key_t *this = malloc_thing(private_agent_private_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
|
||||
this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
|
||||
this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
|
||||
@@ -404,7 +404,7 @@ static agent_private_key_t *agent_private_key_create(char *path,
|
||||
this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
|
||||
|
||||
|
||||
this->socket = open_connection(path);
|
||||
if (this->socket < 0)
|
||||
{
|
||||
@@ -413,7 +413,7 @@ static agent_private_key_t *agent_private_key_create(char *path,
|
||||
}
|
||||
this->key = chunk_empty;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
if (!read_key(this, pubkey))
|
||||
{
|
||||
destroy(this);
|
||||
@@ -442,7 +442,7 @@ struct private_builder_t {
|
||||
static agent_private_key_t *build(private_builder_t *this)
|
||||
{
|
||||
agent_private_key_t *key = NULL;
|
||||
|
||||
|
||||
if (this->socket)
|
||||
{
|
||||
key = agent_private_key_create(this->socket, this->pubkey);
|
||||
@@ -457,7 +457,7 @@ static agent_private_key_t *build(private_builder_t *this)
|
||||
static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_AGENT_SOCKET:
|
||||
@@ -486,19 +486,19 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *agent_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->pubkey = NULL;
|
||||
this->socket = NULL;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson ([email protected]).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson ([email protected]).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson ([email protected]).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -64,262 +64,262 @@ static const BF_KEY bf_init= {
|
||||
0xc0ac29b7L, 0xc97c50ddL, 0x3f84d5b5L, 0xb5470917L,
|
||||
0x9216d5d9L, 0x8979fb1b
|
||||
},{
|
||||
0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L,
|
||||
0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L,
|
||||
0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L,
|
||||
0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL,
|
||||
0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL,
|
||||
0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L,
|
||||
0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL,
|
||||
0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL,
|
||||
0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L,
|
||||
0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L,
|
||||
0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL,
|
||||
0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL,
|
||||
0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL,
|
||||
0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L,
|
||||
0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L,
|
||||
0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L,
|
||||
0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L,
|
||||
0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L,
|
||||
0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL,
|
||||
0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L,
|
||||
0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L,
|
||||
0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L,
|
||||
0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L,
|
||||
0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL,
|
||||
0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L,
|
||||
0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL,
|
||||
0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL,
|
||||
0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L,
|
||||
0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL,
|
||||
0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L,
|
||||
0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL,
|
||||
0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L,
|
||||
0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L,
|
||||
0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL,
|
||||
0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L,
|
||||
0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L,
|
||||
0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL,
|
||||
0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L,
|
||||
0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL,
|
||||
0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L,
|
||||
0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L,
|
||||
0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL,
|
||||
0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L,
|
||||
0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L,
|
||||
0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L,
|
||||
0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L,
|
||||
0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L,
|
||||
0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL,
|
||||
0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL,
|
||||
0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L,
|
||||
0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L,
|
||||
0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L,
|
||||
0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L,
|
||||
0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL,
|
||||
0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L,
|
||||
0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL,
|
||||
0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL,
|
||||
0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L,
|
||||
0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L,
|
||||
0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L,
|
||||
0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L,
|
||||
0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L,
|
||||
0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L,
|
||||
0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL,
|
||||
0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L,
|
||||
0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L,
|
||||
0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L,
|
||||
0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL,
|
||||
0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L,
|
||||
0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L,
|
||||
0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL,
|
||||
0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L,
|
||||
0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L,
|
||||
0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L,
|
||||
0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL,
|
||||
0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL,
|
||||
0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L,
|
||||
0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L,
|
||||
0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L,
|
||||
0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L,
|
||||
0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL,
|
||||
0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL,
|
||||
0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL,
|
||||
0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L,
|
||||
0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL,
|
||||
0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L,
|
||||
0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L,
|
||||
0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL,
|
||||
0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL,
|
||||
0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L,
|
||||
0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL,
|
||||
0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L,
|
||||
0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL,
|
||||
0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL,
|
||||
0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L,
|
||||
0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L,
|
||||
0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L,
|
||||
0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L,
|
||||
0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L,
|
||||
0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L,
|
||||
0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L,
|
||||
0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL,
|
||||
0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L,
|
||||
0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL,
|
||||
0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L,
|
||||
0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L,
|
||||
0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L,
|
||||
0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L,
|
||||
0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L,
|
||||
0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L,
|
||||
0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L,
|
||||
0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L,
|
||||
0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L,
|
||||
0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L,
|
||||
0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L,
|
||||
0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L,
|
||||
0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L,
|
||||
0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L,
|
||||
0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L,
|
||||
0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L,
|
||||
0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL,
|
||||
0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL,
|
||||
0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L,
|
||||
0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL,
|
||||
0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L,
|
||||
0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L,
|
||||
0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L,
|
||||
0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L,
|
||||
0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L,
|
||||
0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L,
|
||||
0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL,
|
||||
0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L,
|
||||
0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L,
|
||||
0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L,
|
||||
0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL,
|
||||
0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL,
|
||||
0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL,
|
||||
0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L,
|
||||
0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L,
|
||||
0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL,
|
||||
0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L,
|
||||
0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL,
|
||||
0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L,
|
||||
0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL,
|
||||
0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L,
|
||||
0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL,
|
||||
0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L,
|
||||
0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL,
|
||||
0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L,
|
||||
0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L,
|
||||
0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL,
|
||||
0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L,
|
||||
0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L,
|
||||
0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L,
|
||||
0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L,
|
||||
0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL,
|
||||
0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L,
|
||||
0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL,
|
||||
0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L,
|
||||
0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL,
|
||||
0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L,
|
||||
0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL,
|
||||
0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL,
|
||||
0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL,
|
||||
0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L,
|
||||
0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L,
|
||||
0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL,
|
||||
0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL,
|
||||
0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL,
|
||||
0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL,
|
||||
0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL,
|
||||
0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L,
|
||||
0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L,
|
||||
0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L,
|
||||
0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L,
|
||||
0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL,
|
||||
0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL,
|
||||
0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L,
|
||||
0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L,
|
||||
0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L,
|
||||
0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L,
|
||||
0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L,
|
||||
0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L,
|
||||
0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L,
|
||||
0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L,
|
||||
0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L,
|
||||
0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L,
|
||||
0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL,
|
||||
0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L,
|
||||
0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL,
|
||||
0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L,
|
||||
0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L,
|
||||
0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL,
|
||||
0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL,
|
||||
0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL,
|
||||
0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L,
|
||||
0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L,
|
||||
0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L,
|
||||
0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L,
|
||||
0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L,
|
||||
0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L,
|
||||
0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L,
|
||||
0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L,
|
||||
0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L,
|
||||
0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L,
|
||||
0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L,
|
||||
0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L,
|
||||
0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL,
|
||||
0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL,
|
||||
0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L,
|
||||
0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL,
|
||||
0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL,
|
||||
0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL,
|
||||
0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L,
|
||||
0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL,
|
||||
0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL,
|
||||
0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L,
|
||||
0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L,
|
||||
0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L,
|
||||
0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L,
|
||||
0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL,
|
||||
0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL,
|
||||
0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L,
|
||||
0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L,
|
||||
0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L,
|
||||
0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL,
|
||||
0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L,
|
||||
0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L,
|
||||
0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L,
|
||||
0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL,
|
||||
0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L,
|
||||
0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L,
|
||||
0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L,
|
||||
0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL,
|
||||
0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL,
|
||||
0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L,
|
||||
0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L,
|
||||
0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L,
|
||||
0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L,
|
||||
0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL,
|
||||
0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L,
|
||||
0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL,
|
||||
0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL,
|
||||
0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L,
|
||||
0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L,
|
||||
0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL,
|
||||
0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L,
|
||||
0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL,
|
||||
0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L,
|
||||
0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL,
|
||||
0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L,
|
||||
0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L,
|
||||
0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL,
|
||||
0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L,
|
||||
0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL,
|
||||
0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L,
|
||||
0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L,
|
||||
0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L,
|
||||
0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L,
|
||||
0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL,
|
||||
0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL,
|
||||
0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L,
|
||||
0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL,
|
||||
0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL,
|
||||
0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L,
|
||||
0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L,
|
||||
0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL,
|
||||
0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL,
|
||||
0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL,
|
||||
0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L,
|
||||
0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L,
|
||||
0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L,
|
||||
0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L,
|
||||
0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L,
|
||||
0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL,
|
||||
0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L,
|
||||
0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L,
|
||||
0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L,
|
||||
0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L,
|
||||
0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL,
|
||||
0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L,
|
||||
0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL,
|
||||
0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL,
|
||||
0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L,
|
||||
0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL,
|
||||
0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L,
|
||||
0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL,
|
||||
0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L,
|
||||
0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L,
|
||||
0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL,
|
||||
0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L,
|
||||
0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L,
|
||||
0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL,
|
||||
0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L,
|
||||
0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL,
|
||||
0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L,
|
||||
0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L,
|
||||
0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL,
|
||||
0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L,
|
||||
0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L,
|
||||
0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L,
|
||||
0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L,
|
||||
0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L,
|
||||
0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL,
|
||||
0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL,
|
||||
0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L,
|
||||
0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L,
|
||||
0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L,
|
||||
0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L,
|
||||
0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL,
|
||||
0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L,
|
||||
0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL,
|
||||
0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL,
|
||||
0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L,
|
||||
0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L,
|
||||
0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L,
|
||||
0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L,
|
||||
0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L,
|
||||
0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L,
|
||||
0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL,
|
||||
0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L,
|
||||
0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L,
|
||||
0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L,
|
||||
0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL,
|
||||
0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L,
|
||||
0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L,
|
||||
0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL,
|
||||
0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L,
|
||||
0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L,
|
||||
0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L,
|
||||
0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL,
|
||||
0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL,
|
||||
0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L,
|
||||
0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L,
|
||||
0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L,
|
||||
0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L,
|
||||
0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL,
|
||||
0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL,
|
||||
0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL,
|
||||
0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L,
|
||||
0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL,
|
||||
0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L,
|
||||
0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L,
|
||||
0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL,
|
||||
0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL,
|
||||
0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L,
|
||||
0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL,
|
||||
0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L,
|
||||
0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL,
|
||||
0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL,
|
||||
0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L,
|
||||
0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L,
|
||||
0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L,
|
||||
0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L,
|
||||
0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L,
|
||||
0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L,
|
||||
0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L,
|
||||
0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL,
|
||||
0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L,
|
||||
0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL,
|
||||
0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L,
|
||||
0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L,
|
||||
0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L,
|
||||
0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L,
|
||||
0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L,
|
||||
0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L,
|
||||
0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L,
|
||||
0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L,
|
||||
0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L,
|
||||
0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L,
|
||||
0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L,
|
||||
0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L,
|
||||
0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L,
|
||||
0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L,
|
||||
0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L,
|
||||
0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L,
|
||||
0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL,
|
||||
0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL,
|
||||
0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L,
|
||||
0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL,
|
||||
0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L,
|
||||
0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L,
|
||||
0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L,
|
||||
0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L,
|
||||
0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L,
|
||||
0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L,
|
||||
0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL,
|
||||
0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L,
|
||||
0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L,
|
||||
0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L,
|
||||
0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL,
|
||||
0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL,
|
||||
0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL,
|
||||
0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L,
|
||||
0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L,
|
||||
0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL,
|
||||
0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L,
|
||||
0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL,
|
||||
0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L,
|
||||
0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL,
|
||||
0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L,
|
||||
0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL,
|
||||
0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L,
|
||||
0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL,
|
||||
0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L,
|
||||
0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L,
|
||||
0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL,
|
||||
0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L,
|
||||
0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L,
|
||||
0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L,
|
||||
0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L,
|
||||
0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL,
|
||||
0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L,
|
||||
0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL,
|
||||
0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L,
|
||||
0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL,
|
||||
0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L,
|
||||
0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL,
|
||||
0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL,
|
||||
0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL,
|
||||
0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L,
|
||||
0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L,
|
||||
0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL,
|
||||
0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL,
|
||||
0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL,
|
||||
0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL,
|
||||
0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL,
|
||||
0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L,
|
||||
0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L,
|
||||
0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L,
|
||||
0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L,
|
||||
0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL,
|
||||
0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL,
|
||||
0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L,
|
||||
0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L,
|
||||
0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L,
|
||||
0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L,
|
||||
0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L,
|
||||
0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L,
|
||||
0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L,
|
||||
0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L,
|
||||
0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L,
|
||||
0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L,
|
||||
0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL,
|
||||
0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L,
|
||||
0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL,
|
||||
0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L,
|
||||
0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L,
|
||||
0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL,
|
||||
0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL,
|
||||
0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL,
|
||||
0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L,
|
||||
0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L,
|
||||
0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L,
|
||||
0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L,
|
||||
0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L,
|
||||
0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L,
|
||||
0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L,
|
||||
0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L,
|
||||
0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L,
|
||||
0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L,
|
||||
0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L,
|
||||
0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L,
|
||||
0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL,
|
||||
0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL,
|
||||
0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L,
|
||||
0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL,
|
||||
0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL,
|
||||
0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL,
|
||||
0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L,
|
||||
0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL,
|
||||
0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL,
|
||||
0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L,
|
||||
0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L,
|
||||
0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L,
|
||||
0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L,
|
||||
0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL,
|
||||
0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL,
|
||||
0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L,
|
||||
0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L,
|
||||
0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L,
|
||||
0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL,
|
||||
0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L,
|
||||
0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L,
|
||||
0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L,
|
||||
0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL,
|
||||
0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L,
|
||||
0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L,
|
||||
0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L,
|
||||
0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL,
|
||||
0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL,
|
||||
0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L,
|
||||
0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L,
|
||||
0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L,
|
||||
0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L,
|
||||
0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL,
|
||||
0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L,
|
||||
0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL,
|
||||
0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL,
|
||||
0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L,
|
||||
0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L,
|
||||
0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL,
|
||||
0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L,
|
||||
0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL,
|
||||
0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L,
|
||||
0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL,
|
||||
0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L,
|
||||
0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L,
|
||||
0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL,
|
||||
0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L,
|
||||
0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL,
|
||||
0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson ([email protected]).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson ([email protected]).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -90,7 +90,7 @@ extern "C" {
|
||||
* So I've chosen long...
|
||||
* <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
/* des.h-like hack <[email protected]> */
|
||||
#ifndef BF_LONG
|
||||
#ifdef __KERNEL__
|
||||
@@ -110,7 +110,7 @@ typedef struct bf_key_st
|
||||
BF_LONG S[4*256];
|
||||
} BF_KEY;
|
||||
|
||||
|
||||
|
||||
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
|
||||
|
||||
void BF_encrypt(BF_LONG *data,const BF_KEY *key);
|
||||
|
||||
@@ -4,21 +4,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson ([email protected]).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -33,10 +33,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -48,7 +48,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -61,23 +61,23 @@
|
||||
* (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
|
||||
* CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
|
||||
*/
|
||||
|
||||
|
||||
#include "blowfish_crypter.h"
|
||||
|
||||
typedef struct private_blowfish_crypter_t private_blowfish_crypter_t;
|
||||
|
||||
/**
|
||||
* Class implementing the Blowfish symmetric encryption algorithm.
|
||||
*
|
||||
*
|
||||
* @ingroup crypters
|
||||
*/
|
||||
struct private_blowfish_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
blowfish_crypter_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Blowfish key schedule
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ static void decrypt(private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *decrypted)
|
||||
{
|
||||
u_int8_t *in, *out;
|
||||
|
||||
|
||||
if (decrypted)
|
||||
{
|
||||
*decrypted = chunk_alloc(data.len);
|
||||
@@ -121,7 +121,7 @@ static void encrypt (private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *encrypted)
|
||||
{
|
||||
u_int8_t *in, *out;
|
||||
|
||||
|
||||
if (encrypted)
|
||||
{
|
||||
*encrypted = chunk_alloc(data.len);
|
||||
@@ -177,14 +177,14 @@ static void destroy (private_blowfish_crypter_t *this)
|
||||
blowfish_crypter_t *blowfish_crypter_create(encryption_algorithm_t algo, size_t key_size)
|
||||
{
|
||||
private_blowfish_crypter_t *this;
|
||||
|
||||
|
||||
if (algo != ENCR_BLOWFISH)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_blowfish_crypter_t);
|
||||
|
||||
|
||||
this->key_size = 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;
|
||||
@@ -192,6 +192,6 @@ blowfish_crypter_t *blowfish_crypter_create(encryption_algorithm_t algo, size_t
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct blowfish_crypter_t blowfish_crypter_t;
|
||||
* Class implementing the Blowfish encryption algorithm.
|
||||
*/
|
||||
struct blowfish_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* The crypter_t interface.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ struct blowfish_crypter_t {
|
||||
|
||||
/**
|
||||
* Constructor to create blowfish_crypter_t objects.
|
||||
*
|
||||
*
|
||||
* @param key_size key size in bytes
|
||||
* @param algo algorithm to implement
|
||||
* @return blowfish_crypter_t object, NULL if not supported
|
||||
|
||||
@@ -48,12 +48,12 @@ static void destroy(private_blowfish_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_blowfish_plugin_t *this = malloc_thing(private_blowfish_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH,
|
||||
(crypter_constructor_t)blowfish_crypter_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ struct private_curl_fetcher_t {
|
||||
* Public data
|
||||
*/
|
||||
curl_fetcher_t public;
|
||||
|
||||
|
||||
/**
|
||||
* CURL handle
|
||||
*/
|
||||
CURL* curl;
|
||||
|
||||
|
||||
/**
|
||||
* Optional HTTP headers
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ struct private_curl_fetcher_t {
|
||||
static size_t append(void *ptr, size_t size, size_t nmemb, chunk_t *data)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
|
||||
|
||||
data->ptr = (u_char*)realloc(data->ptr, data->len + realsize);
|
||||
if (data->ptr)
|
||||
{
|
||||
@@ -68,9 +68,9 @@ static status_t fetch(private_curl_fetcher_t *this, char *uri, chunk_t *result)
|
||||
{
|
||||
char error[CURL_ERROR_SIZE];
|
||||
status_t status;
|
||||
|
||||
|
||||
*result = chunk_empty;
|
||||
|
||||
|
||||
if (curl_easy_setopt(this->curl, CURLOPT_URL, uri) != CURLE_OK)
|
||||
{ /* URL type not supported by curl */
|
||||
return NOT_SUPPORTED;
|
||||
@@ -85,7 +85,7 @@ static status_t fetch(private_curl_fetcher_t *this, char *uri, chunk_t *result)
|
||||
{
|
||||
curl_easy_setopt(this->curl, CURLOPT_HTTPHEADER, this->headers);
|
||||
}
|
||||
|
||||
|
||||
DBG2(" sending http request to '%s'...", uri);
|
||||
switch (curl_easy_perform(this->curl))
|
||||
{
|
||||
@@ -109,7 +109,7 @@ static status_t fetch(private_curl_fetcher_t *this, char *uri, chunk_t *result)
|
||||
static bool set_option(private_curl_fetcher_t *this, fetcher_option_t option, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, option);
|
||||
switch (option)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ static void destroy(private_curl_fetcher_t *this)
|
||||
curl_fetcher_t *curl_fetcher_create()
|
||||
{
|
||||
private_curl_fetcher_t *this = malloc_thing(private_curl_fetcher_t);
|
||||
|
||||
|
||||
this->curl = curl_easy_init();
|
||||
if (this->curl == NULL)
|
||||
{
|
||||
@@ -178,11 +178,11 @@ curl_fetcher_t *curl_fetcher_create()
|
||||
return NULL;
|
||||
}
|
||||
this->headers = NULL;
|
||||
|
||||
|
||||
this->public.interface.fetch = (status_t(*)(fetcher_t*,char*,chunk_t*))fetch;
|
||||
this->public.interface.set_option = (bool(*)(fetcher_t*, fetcher_option_t option, ...))set_option;
|
||||
this->public.interface.destroy = (void (*)(fetcher_t*))destroy;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ struct curl_fetcher_t {
|
||||
* Implements fetcher interface
|
||||
*/
|
||||
fetcher_t interface;
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a curl_fetcher instance.
|
||||
*/
|
||||
|
||||
@@ -52,24 +52,24 @@ plugin_t *plugin_create()
|
||||
{
|
||||
CURLcode res;
|
||||
private_curl_plugin_t *this = malloc_thing(private_curl_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
res = curl_global_init(CURL_GLOBAL_NOTHING);
|
||||
if (res == CURLE_OK)
|
||||
{
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)curl_fetcher_create, "file://");
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)curl_fetcher_create, "http://");
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)curl_fetcher_create, "https://");
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)curl_fetcher_create, "ftp://");
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1("global libcurl initializing failed: %s, curl disabled",
|
||||
DBG1("global libcurl initializing failed: %s, curl disabled",
|
||||
curl_easy_strerror(res));
|
||||
}
|
||||
return &this->public.plugin;
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young ([email protected]).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to.
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -36,10 +36,10 @@
|
||||
* Eric Young ([email protected])"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson ([email protected])"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -73,17 +73,17 @@ typedef struct private_des_crypter_t private_des_crypter_t;
|
||||
* Private data for des_crypter_t
|
||||
*/
|
||||
struct private_des_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
des_crypter_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Key size, depends on algoritm...
|
||||
*/
|
||||
size_t key_size;
|
||||
|
||||
|
||||
union {
|
||||
/** key schedule for single des */
|
||||
des_key_schedule ks;
|
||||
@@ -141,7 +141,7 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
#define DES_PTR
|
||||
#define DES_RISC1
|
||||
@@ -879,7 +879,7 @@ static int des_set_key(des_cblock *key, des_key_schedule *schedule)
|
||||
c2l(in,c);
|
||||
c2l(in,d);
|
||||
|
||||
/* do PC1 in 60 simple operations */
|
||||
/* do PC1 in 60 simple operations */
|
||||
/* PERM_OP(d,c,t,4,0x0f0f0f0fL);
|
||||
HPERM_OP(c,t,-2, 0xcccc0000L);
|
||||
HPERM_OP(c,t,-1, 0xaaaa0000L);
|
||||
@@ -1037,7 +1037,7 @@ static void des_encrypt(DES_LONG *data, des_key_schedule ks, int enc)
|
||||
/**
|
||||
* DES CBC encrypt decrypt routine
|
||||
*/
|
||||
static void des_cbc_encrypt(des_cblock *input, des_cblock *output, long length,
|
||||
static void des_cbc_encrypt(des_cblock *input, des_cblock *output, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int enc)
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
@@ -1110,7 +1110,7 @@ static void des_cbc_encrypt(des_cblock *input, des_cblock *output, long length,
|
||||
/**
|
||||
* DES ECB encrypt decrypt routine
|
||||
*/
|
||||
static void des_ecb_encrypt(des_cblock *input, des_cblock *output, long length,
|
||||
static void des_ecb_encrypt(des_cblock *input, des_cblock *output, long length,
|
||||
des_key_schedule schedule, int enc)
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
@@ -1260,7 +1260,7 @@ static void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
|
||||
/**
|
||||
* Single block 3DES EDE encrypt routine
|
||||
*/
|
||||
static void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
static void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3)
|
||||
{
|
||||
register DES_LONG l,r;
|
||||
@@ -1283,7 +1283,7 @@ static void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
/**
|
||||
* Single block 3DES EDE decrypt routine
|
||||
*/
|
||||
static void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
static void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3)
|
||||
{
|
||||
register DES_LONG l,r;
|
||||
@@ -1391,7 +1391,7 @@ static void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, long len
|
||||
{
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
|
||||
|
||||
t0=tin0;
|
||||
t1=tin1;
|
||||
|
||||
@@ -1400,7 +1400,7 @@ static void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, long len
|
||||
des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
|
||||
tout0^=xor0;
|
||||
tout1^=xor1;
|
||||
l2cn(tout0,tout1,out,l+8);
|
||||
@@ -1424,7 +1424,7 @@ static void decrypt(private_des_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (decrypted)
|
||||
{
|
||||
@@ -1445,7 +1445,7 @@ static void encrypt(private_des_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
{
|
||||
@@ -1464,7 +1464,7 @@ static void decrypt_ecb(private_des_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *decrypted)
|
||||
{
|
||||
u_int8_t *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (decrypted)
|
||||
{
|
||||
@@ -1482,7 +1482,7 @@ static void encrypt_ecb(private_des_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *encrypted)
|
||||
{
|
||||
u_int8_t *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
{
|
||||
@@ -1501,7 +1501,7 @@ static void decrypt3(private_des_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (decrypted)
|
||||
{
|
||||
@@ -1522,7 +1522,7 @@ static void encrypt3(private_des_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
{
|
||||
@@ -1563,7 +1563,7 @@ static void set_key(private_des_crypter_t *this, chunk_t key)
|
||||
* Implementation of crypter_t.set_key for 3DES.
|
||||
*/
|
||||
static void set_key3(private_des_crypter_t *this, chunk_t key)
|
||||
{
|
||||
{
|
||||
des_set_key((des_cblock*)(key.ptr) + 0, &this->ks3[0]);
|
||||
des_set_key((des_cblock*)(key.ptr) + 1, &this->ks3[1]);
|
||||
des_set_key((des_cblock*)(key.ptr) + 2, &this->ks3[2]);
|
||||
@@ -1583,12 +1583,12 @@ static void destroy(private_des_crypter_t *this)
|
||||
des_crypter_t *des_crypter_create(encryption_algorithm_t algo)
|
||||
{
|
||||
private_des_crypter_t *this = malloc_thing(private_des_crypter_t);
|
||||
|
||||
/* functions of crypter_t interface */
|
||||
|
||||
/* functions of crypter_t interface */
|
||||
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.destroy = (void (*) (crypter_t *)) destroy;
|
||||
|
||||
|
||||
/* use functions depending on algorithm */
|
||||
switch (algo)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct des_crypter_t des_crypter_t;
|
||||
* Class implementing the DES and 3DES encryption algorithms.
|
||||
*/
|
||||
struct des_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* The crypter_t interface.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ struct des_crypter_t {
|
||||
|
||||
/**
|
||||
* Constructor to create des_crypter_t objects.
|
||||
*
|
||||
*
|
||||
* @param algo ENCR_DES for single DES, ENCR_3DES for triple DES
|
||||
* @return des_crypter_t object, NULL if algo not supported
|
||||
*/
|
||||
|
||||
@@ -47,16 +47,16 @@ static void destroy(private_des_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_des_plugin_t *this = malloc_thing(private_des_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
|
||||
(crypter_constructor_t)des_crypter_create);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_DES,
|
||||
(crypter_constructor_t)des_crypter_create);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB,
|
||||
(crypter_constructor_t)des_crypter_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ enum dnskey_algorithm_t {
|
||||
static public_key_t *parse_public_key(chunk_t blob)
|
||||
{
|
||||
dnskey_rr_t *rr = (dnskey_rr_t*)blob.ptr;
|
||||
|
||||
|
||||
if (blob.len < sizeof(dnskey_rr_t))
|
||||
{
|
||||
DBG1("DNSKEY too short");
|
||||
return NULL;
|
||||
}
|
||||
blob = chunk_skip(blob, sizeof(dnskey_rr_t));
|
||||
|
||||
|
||||
switch (rr->algorithm)
|
||||
{
|
||||
case DNSKEY_ALG_RSA_SHA1:
|
||||
@@ -74,13 +74,13 @@ static public_key_t *parse_public_key(chunk_t blob)
|
||||
static public_key_t *parse_rsa_public_key(chunk_t blob)
|
||||
{
|
||||
chunk_t n, e;
|
||||
|
||||
|
||||
if (blob.len < 3)
|
||||
{
|
||||
DBG1("RFC 3110 public key blob too short for exponent length");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (blob.ptr[0])
|
||||
{
|
||||
e.len = blob.ptr[0];
|
||||
@@ -98,7 +98,7 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
|
||||
return NULL;
|
||||
}
|
||||
n = chunk_skip(blob, e.len);
|
||||
|
||||
|
||||
return lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e,
|
||||
BUILD_END);
|
||||
@@ -124,7 +124,7 @@ struct private_builder_t {
|
||||
static public_key_t *build_public(private_builder_t *this)
|
||||
{
|
||||
public_key_t *key = NULL;
|
||||
|
||||
|
||||
switch (this->type)
|
||||
{
|
||||
case KEY_ANY:
|
||||
@@ -146,7 +146,7 @@ static public_key_t *build_public(private_builder_t *this)
|
||||
static void add_public(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_DNSKEY:
|
||||
@@ -168,19 +168,19 @@ static void add_public(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *dnskey_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_ANY && type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->blob = chunk_empty;
|
||||
this->type = type;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_public;
|
||||
this->public.build = (void*(*)(builder_t *this))build_public;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ static void destroy(private_dnskey_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_dnskey_plugin_t *this = malloc_thing(private_dnskey_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
|
||||
(builder_constructor_t)dnskey_public_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
(builder_constructor_t)dnskey_public_key_builder);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,22 +29,22 @@ struct private_fips_prf_t {
|
||||
* Public fips_prf_t interface.
|
||||
*/
|
||||
fips_prf_t public;
|
||||
|
||||
|
||||
/**
|
||||
* key of prf function, "b" long
|
||||
*/
|
||||
u_int8_t *key;
|
||||
|
||||
|
||||
/**
|
||||
* size of "b" in bytes
|
||||
*/
|
||||
size_t b;
|
||||
|
||||
|
||||
/**
|
||||
* Keyed SHA1 prf: It does not use SHA1Final operation
|
||||
*/
|
||||
prf_t *keyed_prf;
|
||||
|
||||
|
||||
/**
|
||||
* G function, either SHA1 or DES
|
||||
*/
|
||||
@@ -57,11 +57,11 @@ struct private_fips_prf_t {
|
||||
static void add_mod(size_t length, u_int8_t a[], u_int8_t b[], u_int8_t sum[])
|
||||
{
|
||||
int i, c = 0;
|
||||
|
||||
|
||||
for(i = length - 1; i >= 0; i--)
|
||||
{
|
||||
u_int32_t tmp;
|
||||
|
||||
|
||||
tmp = a[i] + b[i] + c;
|
||||
sum[i] = 0xff & tmp;
|
||||
c = tmp >> 8;
|
||||
@@ -115,13 +115,13 @@ static void get_bytes(private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
|
||||
u_int8_t *xkey = this->key;
|
||||
u_int8_t one[this->b];
|
||||
chunk_t xval_chunk = chunk_from_buf(xval);
|
||||
|
||||
|
||||
memset(one, 0, this->b);
|
||||
one[this->b - 1] = 0x01;
|
||||
|
||||
|
||||
/* 3.1 */
|
||||
chunk_mod(this->b, seed, xseed);
|
||||
|
||||
|
||||
/* 3.2 */
|
||||
for (i = 0; i < 2; i++) /* twice */
|
||||
{
|
||||
@@ -136,7 +136,7 @@ static void get_bytes(private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
|
||||
add_mod(this->b, sum, one, xkey);
|
||||
DBG3("XKEY %b", xkey, this->b);
|
||||
}
|
||||
|
||||
|
||||
/* 3.3 done already, mod q not used */
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ static void set_key(private_fips_prf_t *this, chunk_t key)
|
||||
void g_sha1(private_fips_prf_t *this, chunk_t c, u_int8_t res[])
|
||||
{
|
||||
u_int8_t buf[64];
|
||||
|
||||
|
||||
if (c.len < sizeof(buf))
|
||||
{
|
||||
/* pad c with zeros */
|
||||
@@ -193,7 +193,7 @@ void g_sha1(private_fips_prf_t *this, chunk_t c, u_int8_t res[])
|
||||
/* not more than 512 bits can be G()-ed */
|
||||
c.len = sizeof(buf);
|
||||
}
|
||||
|
||||
|
||||
/* use the keyed hasher, but use an empty key to use SHA1 IV */
|
||||
this->keyed_prf->set_key(this->keyed_prf, chunk_empty);
|
||||
this->keyed_prf->get_bytes(this->keyed_prf, c, res);
|
||||
@@ -215,14 +215,14 @@ static void destroy(private_fips_prf_t *this)
|
||||
fips_prf_t *fips_prf_create(pseudo_random_function_t algo)
|
||||
{
|
||||
private_fips_prf_t *this = malloc_thing(private_fips_prf_t);
|
||||
|
||||
|
||||
this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
|
||||
this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
|
||||
this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
|
||||
this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
|
||||
this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
|
||||
this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
|
||||
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case PRF_FIPS_SHA1_160:
|
||||
@@ -244,7 +244,7 @@ fips_prf_t *fips_prf_create(pseudo_random_function_t algo)
|
||||
return NULL;
|
||||
}
|
||||
this->key = malloc(this->b);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct fips_prf_t fips_prf_t;
|
||||
* The FIPS PRF is stateful; the key changes every time when bytes are acquired.
|
||||
*/
|
||||
struct fips_prf_t {
|
||||
|
||||
|
||||
/**
|
||||
* Generic prf_t interface for this fips_prf_t class.
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ struct fips_prf_t {
|
||||
|
||||
/**
|
||||
* Creates a new fips_prf_t object.
|
||||
*
|
||||
*
|
||||
* FIPS 186-2 defines G() functions used in the PRF function. It can
|
||||
* be implemented either based on SHA1 or DES.
|
||||
* The G() function is selected using the algo parameter.
|
||||
|
||||
@@ -47,11 +47,11 @@ static void destroy(private_fips_prf_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_fips_prf_plugin_t *this = malloc_thing(private_fips_prf_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160,
|
||||
(prf_constructor_t)fips_prf_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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
|
||||
@@ -25,17 +25,17 @@ typedef struct private_gcrypt_crypter_t private_gcrypt_crypter_t;
|
||||
* Private data of gcrypt_crypter_t
|
||||
*/
|
||||
struct private_gcrypt_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
gcrypt_crypter_t public;
|
||||
|
||||
|
||||
/**
|
||||
* gcrypt cipher handle
|
||||
*/
|
||||
gcry_cipher_hd_t h;
|
||||
|
||||
|
||||
/**
|
||||
* gcrypt algorithm identifier
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ static void decrypt(private_gcrypt_crypter_t *this, chunk_t data,
|
||||
chunk_t iv, chunk_t *dst)
|
||||
{
|
||||
gcry_cipher_setiv(this->h, iv.ptr, iv.len);
|
||||
|
||||
|
||||
if (dst)
|
||||
{
|
||||
*dst = chunk_alloc(data.len);
|
||||
@@ -68,7 +68,7 @@ static void encrypt(private_gcrypt_crypter_t *this, chunk_t data,
|
||||
chunk_t iv, chunk_t *dst)
|
||||
{
|
||||
gcry_cipher_setiv(this->h, iv.ptr, iv.len);
|
||||
|
||||
|
||||
if (dst)
|
||||
{
|
||||
*dst = chunk_alloc(data.len);
|
||||
@@ -86,7 +86,7 @@ static void encrypt(private_gcrypt_crypter_t *this, chunk_t data,
|
||||
static size_t get_block_size(private_gcrypt_crypter_t *this)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
gcry_cipher_algo_info(this->alg, GCRYCTL_GET_BLKLEN, NULL, &len);
|
||||
return len;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ static size_t get_block_size(private_gcrypt_crypter_t *this)
|
||||
static size_t get_key_size(private_gcrypt_crypter_t *this)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
gcry_cipher_algo_info(this->alg, GCRYCTL_GET_KEYLEN, NULL, &len);
|
||||
return len;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ gcrypt_crypter_t *gcrypt_crypter_create(encryption_algorithm_t algo,
|
||||
int gcrypt_alg;
|
||||
int mode = GCRY_CIPHER_MODE_CBC;
|
||||
gcry_error_t err;
|
||||
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case ENCR_DES:
|
||||
@@ -227,9 +227,9 @@ gcrypt_crypter_t *gcrypt_crypter_create(encryption_algorithm_t algo,
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_gcrypt_crypter_t);
|
||||
|
||||
|
||||
this->alg = gcrypt_alg;
|
||||
err = gcry_cipher_open(&this->h, gcrypt_alg, mode, 0);
|
||||
if (err)
|
||||
@@ -239,14 +239,14 @@ gcrypt_crypter_t *gcrypt_crypter_create(encryption_algorithm_t algo,
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct gcrypt_crypter_t gcrypt_crypter_t;
|
||||
* Implementation of crypters using gcrypt.
|
||||
*/
|
||||
struct gcrypt_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* The crypter_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct gcrypt_crypter_t {
|
||||
|
||||
/**
|
||||
* Constructor to create gcrypt_crypter_t.
|
||||
*
|
||||
*
|
||||
* @param algo algorithm to implement
|
||||
* @param key_size key size in bytes
|
||||
* @return gcrypt_crypter_t, NULL if not supported
|
||||
|
||||
@@ -278,7 +278,7 @@ static u_int8_t group18_modulus[] = {
|
||||
|
||||
typedef struct modulus_entry_t modulus_entry_t;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Entry of the modulus list.
|
||||
*/
|
||||
struct modulus_entry_t {
|
||||
@@ -312,7 +312,7 @@ static modulus_entry_t modulus_entries[] = {
|
||||
static modulus_entry_t *find_entry(diffie_hellman_group_t group)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < countof(modulus_entries); i++)
|
||||
{
|
||||
if (modulus_entries[i].group == group)
|
||||
@@ -329,47 +329,47 @@ typedef struct private_gcrypt_dh_t private_gcrypt_dh_t;
|
||||
* Private data of an gcrypt_dh_t object.
|
||||
*/
|
||||
struct private_gcrypt_dh_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public gcrypt_dh_t interface
|
||||
*/
|
||||
gcrypt_dh_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number
|
||||
*/
|
||||
u_int16_t group;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Generator value
|
||||
*/
|
||||
*/
|
||||
gcry_mpi_t g;
|
||||
|
||||
|
||||
/**
|
||||
* Own private value
|
||||
*/
|
||||
gcry_mpi_t xa;
|
||||
|
||||
|
||||
/**
|
||||
* Own public value
|
||||
*/
|
||||
gcry_mpi_t ya;
|
||||
|
||||
|
||||
/**
|
||||
* Other public value
|
||||
*/
|
||||
gcry_mpi_t yb;
|
||||
|
||||
|
||||
/**
|
||||
* Shared secret
|
||||
*/
|
||||
gcry_mpi_t zz;
|
||||
|
||||
|
||||
/**
|
||||
* Modulus
|
||||
*/
|
||||
gcry_mpi_t p;
|
||||
|
||||
|
||||
/**
|
||||
* Modulus length.
|
||||
*/
|
||||
@@ -383,7 +383,7 @@ static void set_other_public_value(private_gcrypt_dh_t *this, chunk_t value)
|
||||
{
|
||||
gcry_mpi_t p_min_1;
|
||||
gcry_error_t err;
|
||||
|
||||
|
||||
if (this->yb)
|
||||
{
|
||||
gcry_mpi_release(this->yb);
|
||||
@@ -395,11 +395,11 @@ static void set_other_public_value(private_gcrypt_dh_t *this, chunk_t value)
|
||||
DBG1("importing mpi yb failed: %s", gpg_strerror(err));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
p_min_1 = gcry_mpi_new(this->p_len * 8);
|
||||
gcry_mpi_sub_ui(p_min_1, this->p, 1);
|
||||
|
||||
/* check public value:
|
||||
|
||||
/* check public value:
|
||||
* 1. 0 or 1 is invalid as 0^a = 0 and 1^a = 1
|
||||
* 2. a public value larger or equal the modulus is invalid */
|
||||
if (gcry_mpi_cmp_ui(this->yb, 1) > 0 &&
|
||||
@@ -425,7 +425,7 @@ static chunk_t export_mpi(gcry_mpi_t value, size_t len)
|
||||
{
|
||||
chunk_t chunk;
|
||||
size_t written;
|
||||
|
||||
|
||||
chunk = chunk_alloc(len);
|
||||
gcry_mpi_print(GCRYMPI_FMT_USG, chunk.ptr, chunk.len, &written, value);
|
||||
if (written < len)
|
||||
@@ -490,21 +490,21 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
|
||||
chunk_t random;
|
||||
rng_t *rng;
|
||||
size_t len;
|
||||
|
||||
|
||||
entry = find_entry(group);
|
||||
if (!entry)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_gcrypt_dh_t);
|
||||
|
||||
|
||||
this->public.dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
|
||||
this->public.dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
|
||||
this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
|
||||
this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
|
||||
this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
|
||||
|
||||
|
||||
this->group = group;
|
||||
this->p_len = entry->modulus.len;
|
||||
err = gcry_mpi_scan(&this->p, GCRYMPI_FMT_USG,
|
||||
@@ -524,7 +524,7 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
|
||||
{
|
||||
len = entry->opt_len;
|
||||
}
|
||||
|
||||
|
||||
rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
|
||||
if (rng)
|
||||
{ /* prefer external randomizer */
|
||||
@@ -551,14 +551,14 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
|
||||
/* achieve bitsof(p)-1 by setting MSB to 0 */
|
||||
gcry_mpi_clear_bit(this->xa, len * 8 - 1);
|
||||
}
|
||||
|
||||
|
||||
this->g = gcry_mpi_set_ui(NULL, entry->g);
|
||||
this->ya = gcry_mpi_new(this->p_len * 8);
|
||||
this->yb = NULL;
|
||||
this->zz = NULL;
|
||||
|
||||
|
||||
gcry_mpi_powm(this->ya, this->g, this->xa, this->p);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct gcrypt_dh_t gcrypt_dh_t;
|
||||
* Implementation of the Diffie-Hellman algorithm using libgcrypt mpi.
|
||||
*/
|
||||
struct gcrypt_dh_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct gcrypt_dh_t {
|
||||
|
||||
/**
|
||||
* Creates a new gcrypt_dh_t object.
|
||||
*
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @return gcrypt_dh_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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
|
||||
@@ -25,12 +25,12 @@ typedef struct private_gcrypt_hasher_t private_gcrypt_hasher_t;
|
||||
* Private data of gcrypt_hasher_t
|
||||
*/
|
||||
struct private_gcrypt_hasher_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
gcrypt_hasher_t public;
|
||||
|
||||
|
||||
/**
|
||||
* gcrypt hasher context
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ gcrypt_hasher_t *gcrypt_hasher_create(hash_algorithm_t algo)
|
||||
private_gcrypt_hasher_t *this;
|
||||
int gcrypt_alg;
|
||||
gcry_error_t err;
|
||||
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case HASH_MD2:
|
||||
@@ -131,9 +131,9 @@ gcrypt_hasher_t *gcrypt_hasher_create(hash_algorithm_t algo)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_gcrypt_hasher_t);
|
||||
|
||||
|
||||
err = gcry_md_open(&this->hd, gcrypt_alg, 0);
|
||||
if (err)
|
||||
{
|
||||
@@ -142,13 +142,13 @@ gcrypt_hasher_t *gcrypt_hasher_create(hash_algorithm_t algo)
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct gcrypt_hasher_t gcrypt_hasher_t;
|
||||
* Implementation of hashers using libgcrypt.
|
||||
*/
|
||||
struct gcrypt_hasher_t {
|
||||
|
||||
|
||||
/**
|
||||
* The hasher_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct gcrypt_hasher_t {
|
||||
|
||||
/**
|
||||
* Constructor to create gcrypt_hasher_t.
|
||||
*
|
||||
*
|
||||
* @param algo algorithm
|
||||
* @return gcrypt_hasher_t, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ static int mutex_init(void **lock)
|
||||
static int mutex_destroy(void **lock)
|
||||
{
|
||||
mutex_t *mutex = *lock;
|
||||
|
||||
|
||||
mutex->destroy(mutex);
|
||||
return 0;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static int mutex_destroy(void **lock)
|
||||
static int mutex_lock(void **lock)
|
||||
{
|
||||
mutex_t *mutex = *lock;
|
||||
|
||||
|
||||
mutex->lock(mutex);
|
||||
return 0;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ static int mutex_lock(void **lock)
|
||||
static int mutex_unlock(void **lock)
|
||||
{
|
||||
mutex_t *mutex = *lock;
|
||||
|
||||
|
||||
mutex->unlock(mutex);
|
||||
return 0;
|
||||
}
|
||||
@@ -119,15 +119,15 @@ static void destroy(private_gcrypt_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_gcrypt_plugin_t *this;
|
||||
|
||||
|
||||
gcry_control(GCRYCTL_SET_THREAD_CBS, &thread_functions);
|
||||
|
||||
|
||||
if (!gcry_check_version(GCRYPT_VERSION))
|
||||
{
|
||||
DBG1("libgcrypt version mismatch");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* we currently do not use secure memory */
|
||||
gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
|
||||
if (lib->settings->get_bool(lib->settings,
|
||||
@@ -136,11 +136,11 @@ plugin_t *plugin_create()
|
||||
gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0);
|
||||
}
|
||||
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
|
||||
|
||||
|
||||
this = malloc_thing(private_gcrypt_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
/* hashers */
|
||||
lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
|
||||
(hasher_constructor_t)gcrypt_hasher_create);
|
||||
@@ -156,7 +156,7 @@ plugin_t *plugin_create()
|
||||
(hasher_constructor_t)gcrypt_hasher_create);
|
||||
lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
|
||||
(hasher_constructor_t)gcrypt_hasher_create);
|
||||
|
||||
|
||||
/* crypters */
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
|
||||
(crypter_constructor_t)gcrypt_crypter_create);
|
||||
@@ -176,39 +176,39 @@ plugin_t *plugin_create()
|
||||
(crypter_constructor_t)gcrypt_crypter_create);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_TWOFISH_CBC,
|
||||
(crypter_constructor_t)gcrypt_crypter_create);
|
||||
|
||||
|
||||
/* random numbers */
|
||||
lib->crypto->add_rng(lib->crypto, RNG_WEAK,
|
||||
lib->crypto->add_rng(lib->crypto, RNG_WEAK,
|
||||
(rng_constructor_t)gcrypt_rng_create);
|
||||
lib->crypto->add_rng(lib->crypto, RNG_STRONG,
|
||||
lib->crypto->add_rng(lib->crypto, RNG_STRONG,
|
||||
(rng_constructor_t)gcrypt_rng_create);
|
||||
lib->crypto->add_rng(lib->crypto, RNG_TRUE,
|
||||
lib->crypto->add_rng(lib->crypto, RNG_TRUE,
|
||||
(rng_constructor_t)gcrypt_rng_create);
|
||||
|
||||
|
||||
/* diffie hellman groups, using modp */
|
||||
lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
|
||||
(dh_constructor_t)gcrypt_dh_create);
|
||||
|
||||
|
||||
/* RSA */
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
(builder_constructor_t)gcrypt_rsa_private_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
(builder_constructor_t)gcrypt_rsa_public_key_builder);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ struct private_gcrypt_rng_t {
|
||||
* Public gcrypt_rng_t interface.
|
||||
*/
|
||||
gcrypt_rng_t public;
|
||||
|
||||
|
||||
/**
|
||||
* RNG quality of this instance
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ static void destroy(private_gcrypt_rng_t *this)
|
||||
gcrypt_rng_t *gcrypt_rng_create(rng_quality_t quality)
|
||||
{
|
||||
private_gcrypt_rng_t *this;
|
||||
|
||||
|
||||
switch (quality)
|
||||
{
|
||||
case RNG_WEAK:
|
||||
@@ -89,15 +89,15 @@ gcrypt_rng_t *gcrypt_rng_create(rng_quality_t quality)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_gcrypt_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;
|
||||
|
||||
|
||||
this->quality = quality;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup gcrypt_rng gcrypt_rng
|
||||
* @{ @ingroup gcrypt_p
|
||||
@@ -29,7 +29,7 @@ typedef struct gcrypt_rng_t gcrypt_rng_t;
|
||||
* rng_t implementation using libgcrypt.
|
||||
*/
|
||||
struct gcrypt_rng_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements rng_t.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct gcrypt_rng_t {
|
||||
|
||||
/**
|
||||
* Creates an gcrypt_rng_t instance.
|
||||
*
|
||||
*
|
||||
* @param quality required quality of gcryptness
|
||||
* @return created gcrypt_rng_t
|
||||
*/
|
||||
|
||||
@@ -28,17 +28,17 @@ typedef struct private_gcrypt_rsa_private_key_t private_gcrypt_rsa_private_key_t
|
||||
* Private data of a gcrypt_rsa_private_key_t object.
|
||||
*/
|
||||
struct private_gcrypt_rsa_private_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public interface
|
||||
*/
|
||||
gcrypt_rsa_private_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* gcrypt S-expression representing an RSA key
|
||||
*/
|
||||
gcry_sexp_t key;
|
||||
|
||||
|
||||
/**
|
||||
* reference count
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ chunk_t gcrypt_rsa_find_token(gcry_sexp_t sexp, char *name, gcry_sexp_t key)
|
||||
gcry_sexp_t token;
|
||||
chunk_t data = chunk_empty, tmp;
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
token = gcry_sexp_find_token(sexp, name, 1);
|
||||
if (token)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ static bool sign_raw(private_gcrypt_rsa_private_key_t *this,
|
||||
gcry_error_t err;
|
||||
chunk_t em;
|
||||
size_t k;
|
||||
|
||||
|
||||
/* EM = 0x00 || 0x01 || PS || 0x00 || T
|
||||
* PS = 0xFF padding, with length to fill em
|
||||
* T = data
|
||||
@@ -124,7 +124,7 @@ static bool sign_raw(private_gcrypt_rsa_private_key_t *this,
|
||||
em.ptr[1] = 0x01;
|
||||
em.ptr[em.len - data.len - 1] = 0x00;
|
||||
memcpy(em.ptr + em.len - data.len, data.ptr, data.len);
|
||||
|
||||
|
||||
err = gcry_sexp_build(&in, NULL, "(data(flags raw)(value %b))",
|
||||
em.len, em.ptr);
|
||||
chunk_free(&em);
|
||||
@@ -157,7 +157,7 @@ static bool sign_pkcs1(private_gcrypt_rsa_private_key_t *this,
|
||||
gcry_error_t err;
|
||||
gcry_sexp_t in, out;
|
||||
int hash_oid;
|
||||
|
||||
|
||||
hash_oid = hasher_algorithm_to_oid(hash_algorithm);
|
||||
if (hash_oid == OID_UNKNOWN)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ static bool sign_pkcs1(private_gcrypt_rsa_private_key_t *this,
|
||||
}
|
||||
hasher->allocate_hash(hasher, data, &hash);
|
||||
hasher->destroy(hasher);
|
||||
|
||||
|
||||
err = gcry_sexp_build(&in, NULL, "(data(flags pkcs1)(hash %s %b))",
|
||||
hash_name, hash.len, hash.ptr);
|
||||
chunk_free(&hash);
|
||||
@@ -202,7 +202,7 @@ static key_type_t get_type(private_gcrypt_rsa_private_key_t *this)
|
||||
/**
|
||||
* Implementation of gcrypt_rsa_private_key.destroy.
|
||||
*/
|
||||
static bool sign(private_gcrypt_rsa_private_key_t *this, signature_scheme_t scheme,
|
||||
static bool sign(private_gcrypt_rsa_private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *sig)
|
||||
{
|
||||
switch (scheme)
|
||||
@@ -238,7 +238,7 @@ static bool decrypt(private_gcrypt_rsa_private_key_t *this,
|
||||
gcry_sexp_t in, out;
|
||||
chunk_t padded;
|
||||
u_char *pos = NULL;;
|
||||
|
||||
|
||||
err = gcry_sexp_build(&in, NULL, "(enc-val(flags)(rsa(a %b)))",
|
||||
encrypted.len, encrypted.ptr);
|
||||
if (err)
|
||||
@@ -290,15 +290,15 @@ static public_key_t* get_public_key(private_gcrypt_rsa_private_key_t *this)
|
||||
{
|
||||
chunk_t n, e;
|
||||
public_key_t *public;
|
||||
|
||||
|
||||
n = gcrypt_rsa_find_token(this->key, "n", NULL);
|
||||
e = gcrypt_rsa_find_token(this->key, "e", NULL);
|
||||
|
||||
|
||||
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
|
||||
chunk_free(&n);
|
||||
chunk_free(&e);
|
||||
|
||||
|
||||
return public;
|
||||
}
|
||||
|
||||
@@ -312,12 +312,12 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
|
||||
gcry_mpi_t p = NULL, q = NULL, d = NULL, exp1, exp2;
|
||||
gcry_error_t err;
|
||||
bool success;
|
||||
|
||||
|
||||
/* p and q are swapped, gcrypt expects p < q */
|
||||
cp = gcrypt_rsa_find_token(this->key, "q", NULL);
|
||||
cq = gcrypt_rsa_find_token(this->key, "p", NULL);
|
||||
cd = gcrypt_rsa_find_token(this->key, "d", NULL);
|
||||
|
||||
|
||||
err = gcry_mpi_scan(&p, GCRYMPI_FMT_USG, cp.ptr, cp.len, NULL)
|
||||
| gcry_mpi_scan(&q, GCRYMPI_FMT_USG, cq.ptr, cq.len, NULL)
|
||||
| gcry_mpi_scan(&d, GCRYMPI_FMT_USG, cd.ptr, cd.len, NULL);
|
||||
@@ -332,24 +332,24 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
|
||||
DBG1("scanning mpi for export failed: %s", gpg_strerror(err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
gcry_mpi_sub_ui(p, p, 1);
|
||||
exp1 = gcry_mpi_new(gcry_pk_get_nbits(this->key));
|
||||
gcry_mpi_mod(exp1, d, p);
|
||||
gcry_mpi_release(p);
|
||||
|
||||
|
||||
gcry_mpi_sub_ui(q, q, 1);
|
||||
exp2 = gcry_mpi_new(gcry_pk_get_nbits(this->key));
|
||||
gcry_mpi_mod(exp1, d, q);
|
||||
gcry_mpi_release(q);
|
||||
|
||||
|
||||
err = gcry_mpi_aprint(GCRYMPI_FMT_USG, &cexp1.ptr, &cexp1.len, exp1)
|
||||
| gcry_mpi_aprint(GCRYMPI_FMT_USG, &cexp2.ptr, &cexp2.len, exp2);
|
||||
|
||||
|
||||
gcry_mpi_release(d);
|
||||
gcry_mpi_release(exp1);
|
||||
gcry_mpi_release(exp2);
|
||||
|
||||
|
||||
if (err)
|
||||
{
|
||||
DBG1("printing mpi for export failed: %s", gpg_strerror(err));
|
||||
@@ -360,11 +360,11 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
|
||||
chunk_clear(&cexp2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
cn = gcrypt_rsa_find_token(this->key, "n", NULL);
|
||||
ce = gcrypt_rsa_find_token(this->key, "e", NULL);
|
||||
cu = gcrypt_rsa_find_token(this->key, "u", NULL);
|
||||
|
||||
|
||||
success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
KEY_PART_RSA_MODULUS, cn,
|
||||
KEY_PART_RSA_PUB_EXP, ce, KEY_PART_RSA_PRIV_EXP, cd,
|
||||
@@ -379,7 +379,7 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
|
||||
chunk_clear(&cexp1);
|
||||
chunk_clear(&cexp2);
|
||||
chunk_clear(&cu);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -391,14 +391,14 @@ static bool get_fingerprint(private_gcrypt_rsa_private_key_t *this,
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, this, fp))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
n = gcrypt_rsa_find_token(this->key, "n", NULL);
|
||||
e = gcrypt_rsa_find_token(this->key, "e", NULL);
|
||||
|
||||
|
||||
success = lib->encoding->encode(lib->encoding,
|
||||
type, this, fp, KEY_PART_RSA_MODULUS, n,
|
||||
KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
|
||||
@@ -435,7 +435,7 @@ static void destroy(private_gcrypt_rsa_private_key_t *this)
|
||||
static private_gcrypt_rsa_private_key_t *gcrypt_rsa_private_key_create_empty()
|
||||
{
|
||||
private_gcrypt_rsa_private_key_t *this = malloc_thing(private_gcrypt_rsa_private_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
|
||||
this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
|
||||
this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
|
||||
@@ -447,10 +447,10 @@ static private_gcrypt_rsa_private_key_t *gcrypt_rsa_private_key_create_empty()
|
||||
this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -462,14 +462,14 @@ static gcrypt_rsa_private_key_t *generate(size_t key_size)
|
||||
private_gcrypt_rsa_private_key_t *this;
|
||||
gcry_sexp_t param, key;
|
||||
gcry_error_t err;
|
||||
|
||||
|
||||
err = gcry_sexp_build(¶m, NULL, "(genkey(rsa(nbits %d)))", key_size);
|
||||
if (err)
|
||||
{
|
||||
DBG1("building S-expression failed: %s", gpg_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
err = gcry_pk_genkey(&key, param);
|
||||
gcry_sexp_release(param);
|
||||
if (err)
|
||||
@@ -479,7 +479,7 @@ static gcrypt_rsa_private_key_t *generate(size_t key_size)
|
||||
}
|
||||
this = gcrypt_rsa_private_key_create_empty();
|
||||
this->key = key;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ static gcrypt_rsa_private_key_t *load(chunk_t n, chunk_t e, chunk_t d,
|
||||
{
|
||||
gcry_error_t err;
|
||||
private_gcrypt_rsa_private_key_t *this = gcrypt_rsa_private_key_create_empty();
|
||||
|
||||
|
||||
err = gcry_sexp_build(&this->key, NULL,
|
||||
"(private-key(rsa(n %b)(e %b)(d %b)(p %b)(q %b)(u %b)))",
|
||||
n.len, n.ptr, e.len, e.ptr, d.len, d.ptr,
|
||||
@@ -551,7 +551,7 @@ static gcrypt_rsa_private_key_t *build(private_builder_t *this)
|
||||
static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, part);
|
||||
switch (part)
|
||||
{
|
||||
@@ -594,19 +594,19 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *gcrypt_rsa_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->key_size = 0;
|
||||
this->n = this->e = this->d = this->p = this->q = this->u = chunk_empty;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct gcrypt_rsa_private_key_t gcrypt_rsa_private_key_t;
|
||||
* Private_key_t implementation of RSA algorithm using libgcrypt.
|
||||
*/
|
||||
struct gcrypt_rsa_private_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements private_key_t interface
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <gcrypt.h>
|
||||
|
||||
#include "gcrypt_rsa_public_key.h"
|
||||
@@ -29,17 +29,17 @@ typedef struct private_gcrypt_rsa_public_key_t private_gcrypt_rsa_public_key_t;
|
||||
* Private data structure with signing context.
|
||||
*/
|
||||
struct private_gcrypt_rsa_public_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
gcrypt_rsa_public_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* gcrypt S-expression representing an public RSA key
|
||||
*/
|
||||
gcry_sexp_t key;
|
||||
|
||||
|
||||
/**
|
||||
* reference counter
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ static bool verify_raw(private_gcrypt_rsa_public_key_t *this,
|
||||
gcry_error_t err;
|
||||
chunk_t em;
|
||||
size_t k;
|
||||
|
||||
|
||||
/* EM = 0x00 || 0x01 || PS || 0x00 || T
|
||||
* PS = 0xFF padding, with length to fill em
|
||||
* T = data
|
||||
@@ -77,7 +77,7 @@ static bool verify_raw(private_gcrypt_rsa_public_key_t *this,
|
||||
em.ptr[1] = 0x01;
|
||||
em.ptr[em.len - data.len - 1] = 0x00;
|
||||
memcpy(em.ptr + em.len - data.len, data.ptr, data.len);
|
||||
|
||||
|
||||
err = gcry_sexp_build(&in, NULL, "(data(flags raw)(value %b))",
|
||||
em.len, em.ptr);
|
||||
chunk_free(&em);
|
||||
@@ -116,7 +116,7 @@ static bool verify_pkcs1(private_gcrypt_rsa_public_key_t *this,
|
||||
chunk_t hash;
|
||||
gcry_error_t err;
|
||||
gcry_sexp_t in, sig;
|
||||
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, algorithm);
|
||||
if (!hasher)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ static bool verify_pkcs1(private_gcrypt_rsa_public_key_t *this,
|
||||
}
|
||||
hasher->allocate_hash(hasher, data, &hash);
|
||||
hasher->destroy(hasher);
|
||||
|
||||
|
||||
err = gcry_sexp_build(&in, NULL, "(data(flags pkcs1)(hash %s %b))",
|
||||
hash_name, hash.len, hash.ptr);
|
||||
chunk_free(&hash);
|
||||
@@ -133,7 +133,7 @@ static bool verify_pkcs1(private_gcrypt_rsa_public_key_t *this,
|
||||
DBG1("building data S-expression failed: %s", gpg_strerror(err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
err = gcry_sexp_build(&sig, NULL, "(sig-val(rsa(s %b)))",
|
||||
signature.len, signature.ptr);
|
||||
if (err)
|
||||
@@ -198,7 +198,7 @@ static bool encrypt_(private_gcrypt_rsa_public_key_t *this, chunk_t plain,
|
||||
{
|
||||
gcry_sexp_t in, out;
|
||||
gcry_error_t err;
|
||||
|
||||
|
||||
/* "pkcs1" uses PKCS 1.5 (section 8.1) block type 2 encryption:
|
||||
* 00 | 02 | RANDOM | 00 | DATA */
|
||||
err = gcry_sexp_build(&in, NULL, "(data(flags pkcs1)(value %b))",
|
||||
@@ -236,7 +236,7 @@ static bool get_encoding(private_gcrypt_rsa_public_key_t *this,
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
|
||||
|
||||
n = gcrypt_rsa_find_token(this->key, "n", NULL);
|
||||
e = gcrypt_rsa_find_token(this->key, "e", NULL);
|
||||
success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
@@ -244,7 +244,7 @@ static bool get_encoding(private_gcrypt_rsa_public_key_t *this,
|
||||
KEY_PART_END);
|
||||
chunk_free(&n);
|
||||
chunk_free(&e);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -256,14 +256,14 @@ static bool get_fingerprint(private_gcrypt_rsa_public_key_t *this,
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, this, fp))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
n = gcrypt_rsa_find_token(this->key, "n", NULL);
|
||||
e = gcrypt_rsa_find_token(this->key, "e", NULL);
|
||||
|
||||
|
||||
success = lib->encoding->encode(lib->encoding,
|
||||
type, this, fp, KEY_PART_RSA_MODULUS, n,
|
||||
KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
|
||||
@@ -300,7 +300,7 @@ static void destroy(private_gcrypt_rsa_public_key_t *this)
|
||||
static private_gcrypt_rsa_public_key_t *gcrypt_rsa_public_key_create_empty()
|
||||
{
|
||||
private_gcrypt_rsa_public_key_t *this = malloc_thing(private_gcrypt_rsa_public_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(public_key_t *this))get_type;
|
||||
this->public.interface.verify = (bool (*)(public_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t signature))verify;
|
||||
this->public.interface.encrypt = (bool (*)(public_key_t *this, chunk_t crypto, chunk_t *plain))encrypt_;
|
||||
@@ -310,10 +310,10 @@ static private_gcrypt_rsa_public_key_t *gcrypt_rsa_public_key_create_empty()
|
||||
this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (public_key_t* (*)(public_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(public_key_t *this))destroy;
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ static gcrypt_rsa_public_key_t *load(chunk_t n, chunk_t e)
|
||||
{
|
||||
private_gcrypt_rsa_public_key_t *this;
|
||||
gcry_error_t err;
|
||||
|
||||
|
||||
this = gcrypt_rsa_public_key_create_empty();
|
||||
err = gcry_sexp_build(&this->key, NULL, "(public-key(rsa(n %b)(e %b)))",
|
||||
n.len, n.ptr, e.len, e.ptr);
|
||||
@@ -355,7 +355,7 @@ struct private_builder_t {
|
||||
static gcrypt_rsa_public_key_t *build(private_builder_t *this)
|
||||
{
|
||||
gcrypt_rsa_public_key_t *key;
|
||||
|
||||
|
||||
key = load(this->n, this->e);
|
||||
free(this);
|
||||
return key;
|
||||
@@ -367,7 +367,7 @@ static gcrypt_rsa_public_key_t *build(private_builder_t *this)
|
||||
static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, part);
|
||||
switch (part)
|
||||
{
|
||||
@@ -390,18 +390,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *gcrypt_rsa_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->n = this->e = chunk_empty;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ static u_int8_t group18_modulus[] = {
|
||||
|
||||
typedef struct modulus_entry_t modulus_entry_t;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Entry of the modulus list.
|
||||
*/
|
||||
struct modulus_entry_t {
|
||||
@@ -290,25 +290,25 @@ struct modulus_entry_t {
|
||||
* Group number as it is defined in file transform_substructure.h.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
|
||||
|
||||
/**
|
||||
* Pointer to first byte of modulus (network order).
|
||||
*/
|
||||
u_int8_t *modulus;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Length of modulus in bytes.
|
||||
*/
|
||||
*/
|
||||
size_t modulus_len;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Optimum length of exponent in bytes.
|
||||
*/
|
||||
*/
|
||||
size_t opt_exponent_len;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Generator value.
|
||||
*/
|
||||
*/
|
||||
u_int16_t generator;
|
||||
};
|
||||
|
||||
@@ -336,47 +336,47 @@ struct private_gmp_diffie_hellman_t {
|
||||
* Public gmp_diffie_hellman_t interface.
|
||||
*/
|
||||
gmp_diffie_hellman_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
u_int16_t group;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Generator value.
|
||||
*/
|
||||
*/
|
||||
mpz_t g;
|
||||
|
||||
|
||||
/**
|
||||
* My private value.
|
||||
*/
|
||||
mpz_t xa;
|
||||
|
||||
|
||||
/**
|
||||
* My public value.
|
||||
*/
|
||||
mpz_t ya;
|
||||
|
||||
|
||||
/**
|
||||
* Other public value.
|
||||
*/
|
||||
*/
|
||||
mpz_t yb;
|
||||
|
||||
|
||||
/**
|
||||
* Shared secret.
|
||||
*/
|
||||
*/
|
||||
mpz_t zz;
|
||||
|
||||
/**
|
||||
* Modulus.
|
||||
*/
|
||||
mpz_t p;
|
||||
|
||||
|
||||
/**
|
||||
* Modulus length.
|
||||
*/
|
||||
size_t p_len;
|
||||
|
||||
|
||||
/**
|
||||
* Optimal exponent length.
|
||||
*/
|
||||
@@ -394,13 +394,13 @@ struct private_gmp_diffie_hellman_t {
|
||||
static void set_other_public_value(private_gmp_diffie_hellman_t *this, chunk_t value)
|
||||
{
|
||||
mpz_t p_min_1;
|
||||
|
||||
|
||||
mpz_init(p_min_1);
|
||||
mpz_sub_ui(p_min_1, this->p, 1);
|
||||
|
||||
|
||||
mpz_import(this->yb, value.len, 1, 1, 1, 0, value.ptr);
|
||||
|
||||
/* check public value:
|
||||
|
||||
/* check public value:
|
||||
* 1. 0 or 1 is invalid as 0^a = 0 and 1^a = 1
|
||||
* 2. a public value larger or equal the modulus is invalid */
|
||||
if (mpz_cmp_ui(this->yb, 1) > 0 &&
|
||||
@@ -409,7 +409,7 @@ static void set_other_public_value(private_gmp_diffie_hellman_t *this, chunk_t v
|
||||
#ifdef EXTENDED_DH_TEST
|
||||
/* 3. test if y ^ q mod p = 1, where q = (p - 1)/2. */
|
||||
mpz_t q, one;
|
||||
|
||||
|
||||
mpz_init(q);
|
||||
mpz_init(one);
|
||||
mpz_fdiv_q_2exp(q, p_min_1, 1);
|
||||
@@ -483,7 +483,7 @@ static status_t set_modulus(private_gmp_diffie_hellman_t *this)
|
||||
{
|
||||
int i;
|
||||
status_t status = NOT_FOUND;
|
||||
|
||||
|
||||
for (i = 0; i < (sizeof(modulus_entries) / sizeof(modulus_entry_t)); i++)
|
||||
{
|
||||
if (modulus_entries[i].group == this->group)
|
||||
@@ -533,7 +533,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
|
||||
this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
|
||||
this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
|
||||
|
||||
|
||||
/* private variables */
|
||||
this->group = group;
|
||||
mpz_init(this->p);
|
||||
@@ -542,10 +542,10 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
mpz_init(this->xa);
|
||||
mpz_init(this->zz);
|
||||
mpz_init(this->g);
|
||||
|
||||
|
||||
this->computed = FALSE;
|
||||
|
||||
/* find a modulus according to group */
|
||||
|
||||
/* find a modulus according to group */
|
||||
if (set_modulus(this) != SUCCESS)
|
||||
{
|
||||
destroy(this);
|
||||
@@ -561,7 +561,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
|
||||
ansi_x9_42 = lib->settings->get_int(lib->settings,
|
||||
"libstrongswan.dh_exponent_ansi_x9_42", TRUE);
|
||||
exponent_len = (ansi_x9_42) ? this->p_len : this->opt_exponent_len;
|
||||
exponent_len = (ansi_x9_42) ? this->p_len : this->opt_exponent_len;
|
||||
rng->allocate_bytes(rng, exponent_len, &random);
|
||||
rng->destroy(rng);
|
||||
|
||||
@@ -575,7 +575,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
DBG2("size of DH secret exponent: %u bits", mpz_sizeinbase(this->xa, 2));
|
||||
|
||||
mpz_powm(this->ya, this->g, this->xa, this->p);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct gmp_diffie_hellman_t gmp_diffie_hellman_t;
|
||||
* Implementation of the Diffie-Hellman algorithm, as in RFC2631. Uses libgmp.
|
||||
*/
|
||||
struct gmp_diffie_hellman_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ struct gmp_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Creates a new gmp_diffie_hellman_t object.
|
||||
*
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @return gmp_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -53,31 +53,31 @@ static void destroy(private_gmp_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_gmp_plugin_t *this = malloc_thing(private_gmp_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
|
||||
|
||||
lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
|
||||
(dh_constructor_t)gmp_diffie_hellman_create);
|
||||
|
||||
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
(builder_constructor_t)gmp_rsa_private_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
(builder_constructor_t)gmp_rsa_public_key_builder);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* @defgroup gmp_p gmp
|
||||
* @ingroup plugins
|
||||
*
|
||||
*
|
||||
* @defgroup gmp_plugin gmp_plugin
|
||||
* @{ @ingroup gmp_p
|
||||
*/
|
||||
|
||||
@@ -42,52 +42,52 @@ struct private_gmp_rsa_private_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
gmp_rsa_private_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Public modulus.
|
||||
*/
|
||||
mpz_t n;
|
||||
|
||||
|
||||
/**
|
||||
* Public exponent.
|
||||
*/
|
||||
mpz_t e;
|
||||
|
||||
|
||||
/**
|
||||
* Private prime 1.
|
||||
*/
|
||||
mpz_t p;
|
||||
|
||||
|
||||
/**
|
||||
* Private Prime 2.
|
||||
*/
|
||||
mpz_t q;
|
||||
|
||||
|
||||
/**
|
||||
* Private exponent.
|
||||
*/
|
||||
mpz_t d;
|
||||
|
||||
|
||||
/**
|
||||
* Private exponent 1.
|
||||
*/
|
||||
mpz_t exp1;
|
||||
|
||||
|
||||
/**
|
||||
* Private exponent 2.
|
||||
*/
|
||||
mpz_t exp2;
|
||||
|
||||
|
||||
/**
|
||||
* Private coefficient.
|
||||
*/
|
||||
mpz_t coeff;
|
||||
|
||||
|
||||
/**
|
||||
* Keysize in bytes.
|
||||
*/
|
||||
size_t k;
|
||||
|
||||
|
||||
/**
|
||||
* reference count
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ struct private_gmp_rsa_private_key_t {
|
||||
chunk_t gmp_mpz_to_chunk(const mpz_t value)
|
||||
{
|
||||
chunk_t n;
|
||||
|
||||
|
||||
n.len = 1 + mpz_sizeinbase(value, 2) / BITS_PER_BYTE;
|
||||
n.ptr = mpz_export(NULL, NULL, 1, n.len, 1, 0, value);
|
||||
if (n.ptr == NULL)
|
||||
@@ -117,7 +117,7 @@ static void mpz_clear_sensitive(mpz_t z)
|
||||
{
|
||||
size_t len = mpz_size(z) * GMP_LIMB_BITS / BITS_PER_BYTE;
|
||||
u_int8_t *random = alloca(len);
|
||||
|
||||
|
||||
memset(random, 0, len);
|
||||
/* overwrite mpz_t with zero bytes before clearing it */
|
||||
mpz_import(z, len, 1, 1, 1, 0, random);
|
||||
@@ -132,28 +132,28 @@ static status_t compute_prime(private_gmp_rsa_private_key_t *this,
|
||||
{
|
||||
rng_t *rng;
|
||||
chunk_t random_bytes;
|
||||
|
||||
|
||||
rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE);
|
||||
if (!rng)
|
||||
{
|
||||
DBG1("no RNG of quality %N found", rng_quality_names, RNG_TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
||||
mpz_init(*prime);
|
||||
do
|
||||
{
|
||||
rng->allocate_bytes(rng, prime_size, &random_bytes);
|
||||
/* make sure most significant bit is set */
|
||||
random_bytes.ptr[0] = random_bytes.ptr[0] | 0x80;
|
||||
|
||||
|
||||
mpz_import(*prime, random_bytes.len, 1, 1, 1, 0, random_bytes.ptr);
|
||||
mpz_nextprime (*prime, *prime);
|
||||
chunk_clear(&random_bytes);
|
||||
}
|
||||
/* check if it isn't too large */
|
||||
while (((mpz_sizeinbase(*prime, 2) + 7) / 8) > prime_size);
|
||||
|
||||
|
||||
rng->destroy(rng);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -165,32 +165,32 @@ static chunk_t rsadp(private_gmp_rsa_private_key_t *this, chunk_t data)
|
||||
{
|
||||
mpz_t t1, t2;
|
||||
chunk_t decrypted;
|
||||
|
||||
|
||||
mpz_init(t1);
|
||||
mpz_init(t2);
|
||||
|
||||
|
||||
mpz_import(t1, data.len, 1, 1, 1, 0, data.ptr);
|
||||
|
||||
|
||||
mpz_powm(t2, t1, this->exp1, this->p); /* m1 = c^dP mod p */
|
||||
mpz_powm(t1, t1, this->exp2, this->q); /* m2 = c^dQ mod Q */
|
||||
mpz_sub(t2, t2, t1); /* h = qInv (m1 - m2) mod p */
|
||||
mpz_mod(t2, t2, this->p);
|
||||
mpz_mul(t2, t2, this->coeff);
|
||||
mpz_mod(t2, t2, this->p);
|
||||
|
||||
|
||||
mpz_mul(t2, t2, this->q); /* m = m2 + h q */
|
||||
mpz_add(t1, t1, t2);
|
||||
|
||||
|
||||
decrypted.len = this->k;
|
||||
decrypted.ptr = mpz_export(NULL, NULL, 1, decrypted.len, 1, 0, t1);
|
||||
if (decrypted.ptr == NULL)
|
||||
{
|
||||
decrypted.len = 0;
|
||||
}
|
||||
|
||||
|
||||
mpz_clear_sensitive(t1);
|
||||
mpz_clear_sensitive(t2);
|
||||
|
||||
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
|
||||
hasher_t *hasher;
|
||||
chunk_t hash;
|
||||
int hash_oid = hasher_algorithm_to_oid(hash_algorithm);
|
||||
|
||||
|
||||
if (hash_oid == OID_UNKNOWN)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -230,7 +230,7 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
|
||||
}
|
||||
hasher->allocate_hash(hasher, data, &hash);
|
||||
hasher->destroy(hasher);
|
||||
|
||||
|
||||
/* build DER-encoded digestInfo */
|
||||
digestInfo = asn1_wrap(ASN1_SEQUENCE, "mm",
|
||||
asn1_algorithmIdentifier(hash_oid),
|
||||
@@ -246,15 +246,15 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
|
||||
DBG1("unable to sign %d bytes using a %dbit key", data.len, this->k * 8);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* build chunk to rsa-decrypt:
|
||||
* EM = 0x00 || 0x01 || PS || 0x00 || T.
|
||||
* EM = 0x00 || 0x01 || PS || 0x00 || T.
|
||||
* PS = 0xFF padding, with length to fill em
|
||||
* T = encoded_hash
|
||||
*/
|
||||
em.len = this->k;
|
||||
em.ptr = malloc(em.len);
|
||||
|
||||
|
||||
/* fill em with padding */
|
||||
memset(em.ptr, 0xFF, em.len);
|
||||
/* set magic bytes */
|
||||
@@ -266,11 +266,11 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
|
||||
|
||||
/* build signature */
|
||||
*signature = rsasp1(this, em);
|
||||
|
||||
|
||||
free(digestInfo.ptr);
|
||||
free(em.ptr);
|
||||
|
||||
return TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +284,7 @@ static key_type_t get_type(private_gmp_rsa_private_key_t *this)
|
||||
/**
|
||||
* Implementation of gmp_rsa_private_key.sign.
|
||||
*/
|
||||
static bool sign(private_gmp_rsa_private_key_t *this, signature_scheme_t scheme,
|
||||
static bool sign(private_gmp_rsa_private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature)
|
||||
{
|
||||
switch (scheme)
|
||||
@@ -318,7 +318,7 @@ static bool decrypt(private_gmp_rsa_private_key_t *this, chunk_t crypto,
|
||||
{
|
||||
chunk_t em, stripped;
|
||||
bool success = FALSE;
|
||||
|
||||
|
||||
/* rsa decryption using PKCS#1 RSADP */
|
||||
stripped = em = rsadp(this, crypto);
|
||||
|
||||
@@ -364,15 +364,15 @@ static public_key_t* get_public_key(private_gmp_rsa_private_key_t *this)
|
||||
{
|
||||
chunk_t n, e;
|
||||
public_key_t *public;
|
||||
|
||||
|
||||
n = gmp_mpz_to_chunk(this->n);
|
||||
e = gmp_mpz_to_chunk(this->e);
|
||||
|
||||
|
||||
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
|
||||
chunk_free(&n);
|
||||
chunk_free(&e);
|
||||
|
||||
|
||||
return public;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ static bool get_encoding(private_gmp_rsa_private_key_t *this,
|
||||
{
|
||||
chunk_t n, e, d, p, q, exp1, exp2, coeff;
|
||||
bool success;
|
||||
|
||||
|
||||
n = gmp_mpz_to_chunk(this->n);
|
||||
e = gmp_mpz_to_chunk(this->e);
|
||||
d = gmp_mpz_to_chunk(this->d);
|
||||
@@ -409,7 +409,7 @@ static bool get_encoding(private_gmp_rsa_private_key_t *this,
|
||||
exp1 = gmp_mpz_to_chunk(this->exp1);
|
||||
exp2 = gmp_mpz_to_chunk(this->exp2);
|
||||
coeff = gmp_mpz_to_chunk(this->coeff);
|
||||
|
||||
|
||||
success = lib->encoding->encode(lib->encoding,
|
||||
type, NULL, encoding, KEY_PART_RSA_MODULUS, n,
|
||||
KEY_PART_RSA_PUB_EXP, e, KEY_PART_RSA_PRIV_EXP, d,
|
||||
@@ -424,7 +424,7 @@ static bool get_encoding(private_gmp_rsa_private_key_t *this,
|
||||
chunk_clear(&exp1);
|
||||
chunk_clear(&exp2);
|
||||
chunk_clear(&coeff);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -436,19 +436,19 @@ static bool get_fingerprint(private_gmp_rsa_private_key_t *this,
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, this, fp))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
n = gmp_mpz_to_chunk(this->n);
|
||||
e = gmp_mpz_to_chunk(this->e);
|
||||
|
||||
|
||||
success = lib->encoding->encode(lib->encoding, type, this, fp,
|
||||
KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
|
||||
chunk_free(&n);
|
||||
chunk_free(&e);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
{
|
||||
mpz_t t, u, q1;
|
||||
status_t status = SUCCESS;
|
||||
|
||||
|
||||
/* PKCS#1 1.5 section 6 requires modulus to have at least 12 octets.
|
||||
* We actually require more (for security).
|
||||
*/
|
||||
@@ -497,25 +497,25 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
DBG1("key shorter than 512 bits");
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* we picked a max modulus size to simplify buffer allocation */
|
||||
if (this->k > 8192 / BITS_PER_BYTE)
|
||||
{
|
||||
DBG1("key larger than 8192 bits");
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
||||
mpz_init(t);
|
||||
mpz_init(u);
|
||||
mpz_init(q1);
|
||||
|
||||
|
||||
/* check that n == p * q */
|
||||
mpz_mul(u, this->p, this->q);
|
||||
if (mpz_cmp(u, this->n) != 0)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* check that e divides neither p-1 nor q-1 */
|
||||
mpz_sub_ui(t, this->p, 1);
|
||||
mpz_mod(t, t, this->e);
|
||||
@@ -523,14 +523,14 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
mpz_sub_ui(t, this->q, 1);
|
||||
mpz_mod(t, t, this->e);
|
||||
if (mpz_cmp_ui(t, 0) == 0)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* check that d is e^-1 (mod lcm(p-1, q-1)) */
|
||||
/* see PKCS#1v2, aka RFC 2437, for the "lcm" */
|
||||
mpz_sub_ui(q1, this->q, 1);
|
||||
@@ -538,14 +538,14 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
mpz_gcd(t, u, q1); /* t := gcd(p-1, q-1) */
|
||||
mpz_mul(u, u, q1); /* u := (p-1) * (q-1) */
|
||||
mpz_divexact(u, u, t); /* u := lcm(p-1, q-1) */
|
||||
|
||||
|
||||
mpz_mul(t, this->d, this->e);
|
||||
mpz_mod(t, t, u);
|
||||
if (mpz_cmp_ui(t, 1) != 0)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* check that exp1 is d mod (p-1) */
|
||||
mpz_sub_ui(u, this->p, 1);
|
||||
mpz_mod(t, this->d, u);
|
||||
@@ -553,7 +553,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* check that exp2 is d mod (q-1) */
|
||||
mpz_sub_ui(u, this->q, 1);
|
||||
mpz_mod(t, this->d, u);
|
||||
@@ -561,7 +561,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* check that coeff is (q^-1) mod p */
|
||||
mpz_mul(t, this->coeff, this->q);
|
||||
mpz_mod(t, t, this->p);
|
||||
@@ -569,7 +569,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
{
|
||||
status = FAILED;
|
||||
}
|
||||
|
||||
|
||||
mpz_clear_sensitive(t);
|
||||
mpz_clear_sensitive(u);
|
||||
mpz_clear_sensitive(q1);
|
||||
@@ -586,7 +586,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
|
||||
static private_gmp_rsa_private_key_t *gmp_rsa_private_key_create_empty(void)
|
||||
{
|
||||
private_gmp_rsa_private_key_t *this = malloc_thing(private_gmp_rsa_private_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*) (private_key_t*))get_type;
|
||||
this->public.interface.sign = (bool (*) (private_key_t*, signature_scheme_t, chunk_t, chunk_t*))sign;
|
||||
this->public.interface.decrypt = (bool (*) (private_key_t*, chunk_t, chunk_t*))decrypt;
|
||||
@@ -598,9 +598,9 @@ static private_gmp_rsa_private_key_t *gmp_rsa_private_key_create_empty(void)
|
||||
this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (private_key_t* (*) (private_key_t*))get_ref;
|
||||
this->public.interface.destroy = (void (*) (private_key_t*))destroy;
|
||||
|
||||
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -612,35 +612,35 @@ static gmp_rsa_private_key_t *generate(size_t key_size)
|
||||
mpz_t p, q, n, e, d, exp1, exp2, coeff;
|
||||
mpz_t m, q1, t;
|
||||
private_gmp_rsa_private_key_t *this = gmp_rsa_private_key_create_empty();
|
||||
|
||||
|
||||
key_size = key_size / BITS_PER_BYTE;
|
||||
|
||||
|
||||
/* Get values of primes p and q */
|
||||
if (compute_prime(this, key_size/2, &p) != SUCCESS)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (compute_prime(this, key_size/2, &q) != SUCCESS)
|
||||
{
|
||||
mpz_clear(p);
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
mpz_init(t);
|
||||
mpz_init(n);
|
||||
mpz_init(d);
|
||||
mpz_init(exp1);
|
||||
mpz_init(exp2);
|
||||
mpz_init(coeff);
|
||||
|
||||
|
||||
/* Swapping Primes so p is larger then q */
|
||||
if (mpz_cmp(p, q) < 0)
|
||||
{
|
||||
mpz_swap(p, q);
|
||||
}
|
||||
|
||||
|
||||
mpz_mul(n, p, q); /* n = p*q */
|
||||
mpz_init_set_ui(e, PUBLIC_EXPONENT); /* assign public exponent */
|
||||
mpz_init_set(m, p); /* m = p */
|
||||
@@ -661,7 +661,7 @@ static gmp_rsa_private_key_t *generate(size_t key_size)
|
||||
mpz_mod(exp1, d, t); /* exp1 = d mod p-1 */
|
||||
mpz_sub_ui(t, q, 1); /* t = q-1 */
|
||||
mpz_mod(exp2, d, t); /* exp2 = d mod q-1 */
|
||||
|
||||
|
||||
mpz_invert(coeff, q, p); /* coeff = q^-1 mod p */
|
||||
if (mpz_cmp_ui(coeff, 0) < 0) /* make coeff d is positive */
|
||||
{
|
||||
@@ -681,10 +681,10 @@ static gmp_rsa_private_key_t *generate(size_t key_size)
|
||||
*(this->exp1) = *exp1;
|
||||
*(this->exp2) = *exp2;
|
||||
*(this->coeff) = *coeff;
|
||||
|
||||
|
||||
/* set key size in bytes */
|
||||
this->k = key_size;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ static gmp_rsa_private_key_t *load(chunk_t n, chunk_t e, chunk_t d,
|
||||
chunk_t p, chunk_t q, chunk_t exp1, chunk_t exp2, chunk_t coeff)
|
||||
{
|
||||
private_gmp_rsa_private_key_t *this = gmp_rsa_private_key_create_empty();
|
||||
|
||||
|
||||
mpz_init(this->n);
|
||||
mpz_init(this->e);
|
||||
mpz_init(this->p);
|
||||
@@ -704,7 +704,7 @@ static gmp_rsa_private_key_t *load(chunk_t n, chunk_t e, chunk_t d,
|
||||
mpz_init(this->exp1);
|
||||
mpz_init(this->exp2);
|
||||
mpz_init(this->coeff);
|
||||
|
||||
|
||||
mpz_import(this->n, n.len, 1, 1, 1, 0, n.ptr);
|
||||
mpz_import(this->e, e.len, 1, 1, 1, 0, e.ptr);
|
||||
mpz_import(this->d, d.len, 1, 1, 1, 0, d.ptr);
|
||||
@@ -757,7 +757,7 @@ struct private_builder_t {
|
||||
static gmp_rsa_private_key_t *build(private_builder_t *this)
|
||||
{
|
||||
gmp_rsa_private_key_t *key = NULL;
|
||||
|
||||
|
||||
if (this->key_size)
|
||||
{
|
||||
key = generate(this->key_size);
|
||||
@@ -777,7 +777,7 @@ static gmp_rsa_private_key_t *build(private_builder_t *this)
|
||||
static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, part);
|
||||
switch (part)
|
||||
{
|
||||
@@ -821,20 +821,20 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *gmp_rsa_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->n = this->e = this->d = this->p = this->q = chunk_empty;
|
||||
this->exp1 = this->exp2 = this->coeff = chunk_empty;
|
||||
this->key_size = 0;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <gmp.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@@ -38,22 +38,22 @@ struct private_gmp_rsa_public_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
gmp_rsa_public_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Public modulus.
|
||||
*/
|
||||
mpz_t n;
|
||||
|
||||
|
||||
/**
|
||||
* Public exponent.
|
||||
*/
|
||||
mpz_t e;
|
||||
|
||||
|
||||
/**
|
||||
* Keysize in bytes.
|
||||
*/
|
||||
size_t k;
|
||||
|
||||
|
||||
/**
|
||||
* reference counter
|
||||
*/
|
||||
@@ -72,12 +72,12 @@ static chunk_t rsaep(private_gmp_rsa_public_key_t *this, chunk_t data)
|
||||
{
|
||||
mpz_t m, c;
|
||||
chunk_t encrypted;
|
||||
|
||||
|
||||
mpz_init(c);
|
||||
mpz_init(m);
|
||||
|
||||
|
||||
mpz_import(m, data.len, 1, 1, 1, 0, data.ptr);
|
||||
|
||||
|
||||
mpz_powm(c, m, this->e, this->n);
|
||||
|
||||
encrypted.len = this->k;
|
||||
@@ -86,10 +86,10 @@ static chunk_t rsaep(private_gmp_rsa_public_key_t *this, chunk_t data)
|
||||
{
|
||||
encrypted.len = 0;
|
||||
}
|
||||
|
||||
|
||||
mpz_clear(c);
|
||||
mpz_clear(m);
|
||||
|
||||
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
@@ -123,34 +123,34 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
|
||||
{
|
||||
chunk_t em_ori, em;
|
||||
bool success = FALSE;
|
||||
|
||||
|
||||
/* remove any preceding 0-bytes from signature */
|
||||
while (signature.len && *(signature.ptr) == 0x00)
|
||||
{
|
||||
signature = chunk_skip(signature, 1);
|
||||
}
|
||||
|
||||
|
||||
if (signature.len == 0 || signature.len > this->k)
|
||||
{
|
||||
return INVALID_ARG;
|
||||
}
|
||||
|
||||
|
||||
/* unpack signature */
|
||||
em_ori = em = rsavp1(this, signature);
|
||||
|
||||
|
||||
/* result should look like this:
|
||||
* EM = 0x00 || 0x01 || PS || 0x00 || T.
|
||||
* EM = 0x00 || 0x01 || PS || 0x00 || T.
|
||||
* PS = 0xFF padding, with length to fill em
|
||||
* T = oid || hash
|
||||
*/
|
||||
|
||||
|
||||
/* check magic bytes */
|
||||
if (*(em.ptr) != 0x00 || *(em.ptr+1) != 0x01)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
em = chunk_skip(em, 2);
|
||||
|
||||
|
||||
/* find magic 0x00 */
|
||||
while (em.len > 0)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
|
||||
{
|
||||
chunk_t hash;
|
||||
hasher_t *hasher;
|
||||
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, hash_algorithm);
|
||||
if (hasher == NULL)
|
||||
{
|
||||
@@ -277,7 +277,7 @@ static key_type_t get_type(private_gmp_rsa_public_key_t *this)
|
||||
/**
|
||||
* Implementation of public_key_t.verify.
|
||||
*/
|
||||
static bool verify(private_gmp_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
static bool verify(private_gmp_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
@@ -333,9 +333,9 @@ static bool encrypt_(private_gmp_rsa_public_key_t *this, chunk_t plain,
|
||||
|
||||
/* padding according to PKCS#1 7.2.1 (RSAES-PKCS1-v1.5-ENCRYPT) */
|
||||
DBG2("padding %u bytes of data to the rsa modulus size of %u bytes",
|
||||
plain.len, this->k);
|
||||
plain.len, this->k);
|
||||
em.len = this->k;
|
||||
em.ptr = malloc(em.len);
|
||||
em.ptr = malloc(em.len);
|
||||
pos = em.ptr;
|
||||
*pos++ = 0x00;
|
||||
*pos++ = 0x02;
|
||||
@@ -360,7 +360,7 @@ static bool encrypt_(private_gmp_rsa_public_key_t *this, chunk_t plain,
|
||||
/* now add the data */
|
||||
memcpy(pos, plain.ptr, plain.len);
|
||||
DBG3("padded data before rsa encryption: %B", &em);
|
||||
|
||||
|
||||
/* rsa encryption using PKCS#1 RSAEP */
|
||||
*crypto = rsaep(this, em);
|
||||
DBG3("rsa encrypted data: %B", crypto);
|
||||
@@ -392,15 +392,15 @@ static bool get_encoding(private_gmp_rsa_public_key_t *this,
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
|
||||
|
||||
n = gmp_mpz_to_chunk(this->n);
|
||||
e = gmp_mpz_to_chunk(this->e);
|
||||
|
||||
success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
|
||||
success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
|
||||
chunk_free(&n);
|
||||
chunk_free(&e);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -412,19 +412,19 @@ static bool get_fingerprint(private_gmp_rsa_public_key_t *this,
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, this, fp))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
n = gmp_mpz_to_chunk(this->n);
|
||||
e = gmp_mpz_to_chunk(this->e);
|
||||
|
||||
|
||||
success = lib->encoding->encode(lib->encoding, type, this, fp,
|
||||
KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
|
||||
chunk_free(&n);
|
||||
chunk_free(&e);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ static void destroy(private_gmp_rsa_public_key_t *this)
|
||||
static private_gmp_rsa_public_key_t *gmp_rsa_public_key_create_empty()
|
||||
{
|
||||
private_gmp_rsa_public_key_t *this = malloc_thing(private_gmp_rsa_public_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*) (public_key_t*))get_type;
|
||||
this->public.interface.verify = (bool (*) (public_key_t*, signature_scheme_t, chunk_t, chunk_t))verify;
|
||||
this->public.interface.encrypt = (bool (*) (public_key_t*, chunk_t, chunk_t*))encrypt_;
|
||||
@@ -467,9 +467,9 @@ static private_gmp_rsa_public_key_t *gmp_rsa_public_key_create_empty()
|
||||
this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (public_key_t* (*) (public_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*) (public_key_t *this))destroy;
|
||||
|
||||
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -479,15 +479,15 @@ static private_gmp_rsa_public_key_t *gmp_rsa_public_key_create_empty()
|
||||
static gmp_rsa_public_key_t *load(chunk_t n, chunk_t e)
|
||||
{
|
||||
private_gmp_rsa_public_key_t *this = gmp_rsa_public_key_create_empty();
|
||||
|
||||
|
||||
mpz_init(this->n);
|
||||
mpz_init(this->e);
|
||||
|
||||
|
||||
mpz_import(this->n, n.len, 1, 1, 1, 0, n.ptr);
|
||||
mpz_import(this->e, e.len, 1, 1, 1, 0, e.ptr);
|
||||
|
||||
|
||||
this->k = (mpz_sizeinbase(this->n, 2) + 7) / BITS_PER_BYTE;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ struct private_builder_t {
|
||||
static gmp_rsa_public_key_t *build(private_builder_t *this)
|
||||
{
|
||||
gmp_rsa_public_key_t *key;
|
||||
|
||||
|
||||
key = load(this->n, this->e);
|
||||
free(this);
|
||||
return key;
|
||||
@@ -521,7 +521,7 @@ static gmp_rsa_public_key_t *build(private_builder_t *this)
|
||||
static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, part);
|
||||
switch (part)
|
||||
{
|
||||
@@ -544,18 +544,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *gmp_rsa_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->n = this->e = chunk_empty;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef struct private_hmac_t private_hmac_t;
|
||||
|
||||
/**
|
||||
* Private data of a hmac_t object.
|
||||
*
|
||||
*
|
||||
* The variable names are the same as in the RFC.
|
||||
*/
|
||||
struct private_hmac_t {
|
||||
@@ -31,22 +31,22 @@ struct private_hmac_t {
|
||||
* Public hmac_t interface.
|
||||
*/
|
||||
hmac_t hmac;
|
||||
|
||||
|
||||
/**
|
||||
* Block size, as in RFC.
|
||||
*/
|
||||
u_int8_t b;
|
||||
|
||||
|
||||
/**
|
||||
* Hash function.
|
||||
*/
|
||||
hasher_t *h;
|
||||
|
||||
|
||||
/**
|
||||
* Previously xor'ed key using opad.
|
||||
*/
|
||||
chunk_t opaded_key;
|
||||
|
||||
|
||||
/**
|
||||
* Previously xor'ed key using ipad.
|
||||
*/
|
||||
@@ -58,16 +58,16 @@ struct private_hmac_t {
|
||||
*/
|
||||
static void get_mac(private_hmac_t *this, chunk_t data, u_int8_t *out)
|
||||
{
|
||||
/* H(K XOR opad, H(K XOR ipad, text))
|
||||
*
|
||||
/* H(K XOR opad, H(K XOR ipad, text))
|
||||
*
|
||||
* if out is NULL, we append text to the inner hash.
|
||||
* else, we complete the inner and do the outer.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
u_int8_t buffer[this->h->get_hash_size(this->h)];
|
||||
chunk_t inner;
|
||||
|
||||
|
||||
if (out == NULL)
|
||||
{
|
||||
/* append data to inner */
|
||||
@@ -78,14 +78,14 @@ static void get_mac(private_hmac_t *this, chunk_t data, u_int8_t *out)
|
||||
/* append and do outer hash */
|
||||
inner.ptr = buffer;
|
||||
inner.len = this->h->get_hash_size(this->h);
|
||||
|
||||
|
||||
/* complete inner */
|
||||
this->h->get_hash(this->h, data, buffer);
|
||||
|
||||
|
||||
/* do outer */
|
||||
this->h->get_hash(this->h, this->opaded_key, NULL);
|
||||
this->h->get_hash(this->h, inner, out);
|
||||
|
||||
|
||||
/* reinit for next call */
|
||||
this->h->get_hash(this->h, this->ipaded_key, NULL);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ static void allocate_mac(private_hmac_t *this, chunk_t data, chunk_t *out)
|
||||
this->hmac.get_mac(&(this->hmac), data, out->ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of hmac_t.get_block_size.
|
||||
*/
|
||||
@@ -125,27 +125,27 @@ static void set_key(private_hmac_t *this, chunk_t key)
|
||||
{
|
||||
int i;
|
||||
u_int8_t buffer[this->b];
|
||||
|
||||
|
||||
memset(buffer, 0, this->b);
|
||||
|
||||
|
||||
if (key.len > this->b)
|
||||
{
|
||||
{
|
||||
/* if key is too long, it will be hashed */
|
||||
this->h->get_hash(this->h, key, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
/* if not, just copy it in our pre-padded k */
|
||||
memcpy(buffer, key.ptr, key.len);
|
||||
memcpy(buffer, key.ptr, key.len);
|
||||
}
|
||||
|
||||
|
||||
/* apply ipad and opad to key */
|
||||
for (i = 0; i < this->b; i++)
|
||||
{
|
||||
this->ipaded_key.ptr[i] = buffer[i] ^ 0x36;
|
||||
this->opaded_key.ptr[i] = buffer[i] ^ 0x5C;
|
||||
}
|
||||
|
||||
|
||||
/* begin hashing of inner pad */
|
||||
this->h->reset(this->h);
|
||||
this->h->get_hash(this->h, this->ipaded_key, NULL);
|
||||
@@ -175,7 +175,7 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
|
||||
this->hmac.get_block_size = (size_t (*)(hmac_t *))get_block_size;
|
||||
this->hmac.set_key = (void (*)(hmac_t *,chunk_t))set_key;
|
||||
this->hmac.destroy = (void (*)(hmac_t *))destroy;
|
||||
|
||||
|
||||
/* set b, according to hasher */
|
||||
switch (hash_algorithm)
|
||||
{
|
||||
@@ -190,15 +190,15 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
|
||||
break;
|
||||
default:
|
||||
free(this);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* build the hasher */
|
||||
this->h = lib->crypto->create_hasher(lib->crypto, hash_algorithm);
|
||||
if (this->h == NULL)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* build ipad and opad */
|
||||
|
||||
@@ -36,46 +36,46 @@ typedef struct hmac_t hmac_t;
|
||||
struct hmac_t {
|
||||
/**
|
||||
* Generate message authentication code.
|
||||
*
|
||||
*
|
||||
* If buffer is NULL, no result is given back. A next call will
|
||||
* append the data to already supplied data. If buffer is not NULL,
|
||||
* append the data to already supplied data. If buffer is not NULL,
|
||||
* the mac of all apended data is calculated, returned and the
|
||||
* state of the hmac_t is reseted.
|
||||
*
|
||||
*
|
||||
* @param data chunk of data to authenticate
|
||||
* @param buffer pointer where the generated bytes will be written
|
||||
*/
|
||||
void (*get_mac) (hmac_t *this, chunk_t data, u_int8_t *buffer);
|
||||
|
||||
|
||||
/**
|
||||
* Generates message authentication code and allocate space for them.
|
||||
*
|
||||
*
|
||||
* If chunk is NULL, no result is given back. A next call will
|
||||
* append the data to already supplied. If chunk is not NULL,
|
||||
* append the data to already supplied. If chunk is not NULL,
|
||||
* the mac of all apended data is calculated, returned and the
|
||||
* state of the hmac_t reset;
|
||||
*
|
||||
*
|
||||
* @param data chunk of data to authenticate
|
||||
* @param chunk chunk which will hold generated bytes
|
||||
*/
|
||||
void (*allocate_mac) (hmac_t *this, chunk_t data, chunk_t *chunk);
|
||||
|
||||
|
||||
/**
|
||||
* Get the block size of this hmac_t object.
|
||||
*
|
||||
*
|
||||
* @return block size in bytes
|
||||
*/
|
||||
size_t (*get_block_size) (hmac_t *this);
|
||||
|
||||
size_t (*get_block_size) (hmac_t *this);
|
||||
|
||||
/**
|
||||
* Set the key for this hmac_t object.
|
||||
*
|
||||
*
|
||||
* Any key length is accepted.
|
||||
*
|
||||
*
|
||||
* @param key key to set
|
||||
*/
|
||||
void (*set_key) (hmac_t *this, chunk_t key);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a hmac_t object.
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ struct hmac_t {
|
||||
|
||||
/**
|
||||
* Creates a new hmac_t object.
|
||||
*
|
||||
*
|
||||
* @param hash_algorithm hash algorithm to use
|
||||
* @return hmac_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -50,35 +50,35 @@ static void destroy(private_hmac_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_hmac_plugin_t *this = malloc_thing(private_hmac_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256,
|
||||
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1,
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5,
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384,
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512,
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96,
|
||||
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256,
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
|
||||
return &this->public.plugin;
|
||||
|
||||
@@ -28,8 +28,8 @@ struct private_hmac_prf_t {
|
||||
/**
|
||||
* Public hmac_prf_t interface.
|
||||
*/
|
||||
hmac_prf_t public;
|
||||
|
||||
hmac_prf_t public;
|
||||
|
||||
/**
|
||||
* Hmac to use for generation.
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ hmac_prf_t *hmac_prf_create(pseudo_random_function_t algo)
|
||||
{
|
||||
private_hmac_prf_t *this;
|
||||
hash_algorithm_t hash;
|
||||
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case PRF_HMAC_SHA1:
|
||||
@@ -114,22 +114,22 @@ hmac_prf_t *hmac_prf_create(pseudo_random_function_t algo)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_hmac_prf_t);
|
||||
this->hmac = hmac_create(hash);
|
||||
if (this->hmac == NULL)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
|
||||
this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
|
||||
this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
|
||||
this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
|
||||
this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
|
||||
this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
|
||||
|
||||
|
||||
return &(this->public);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ typedef struct hmac_prf_t hmac_prf_t;
|
||||
|
||||
/**
|
||||
* Implementation of prf_t interface using the HMAC algorithm.
|
||||
*
|
||||
*
|
||||
* This simply wraps a hmac_t in a prf_t. More a question of
|
||||
* interface matching.
|
||||
*/
|
||||
struct hmac_prf_t {
|
||||
|
||||
|
||||
/**
|
||||
* Generic prf_t interface for this hmac_prf_t class.
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ struct hmac_prf_t {
|
||||
|
||||
/**
|
||||
* Creates a new hmac_prf_t object.
|
||||
*
|
||||
*
|
||||
* @param algo algorithm to implement
|
||||
* @return hmac_prf_t object, NULL if hash not supported
|
||||
*/
|
||||
|
||||
@@ -29,12 +29,12 @@ struct private_hmac_signer_t {
|
||||
* Public interface of hmac_signer_t.
|
||||
*/
|
||||
hmac_signer_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Assigned hmac function.
|
||||
*/
|
||||
hmac_t *hmac;
|
||||
|
||||
|
||||
/**
|
||||
* Block size (truncation of HMAC Hash)
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ static void get_signature(private_hmac_signer_t *this,
|
||||
else
|
||||
{
|
||||
u_int8_t mac[this->hmac->get_block_size(this->hmac)];
|
||||
|
||||
|
||||
this->hmac->get_mac(this->hmac, data, mac);
|
||||
memcpy(buffer, mac, this->block_size);
|
||||
}
|
||||
@@ -73,12 +73,12 @@ static void allocate_signature (private_hmac_signer_t *this,
|
||||
else
|
||||
{
|
||||
u_int8_t mac[this->hmac->get_block_size(this->hmac)];
|
||||
|
||||
|
||||
this->hmac->get_mac(this->hmac, data, mac);
|
||||
|
||||
chunk->ptr = malloc(this->block_size);
|
||||
chunk->len = this->block_size;
|
||||
|
||||
|
||||
memcpy(chunk->ptr, mac, this->block_size);
|
||||
}
|
||||
}
|
||||
@@ -90,9 +90,9 @@ static bool verify_signature(private_hmac_signer_t *this,
|
||||
chunk_t data, chunk_t signature)
|
||||
{
|
||||
u_int8_t mac[this->hmac->get_block_size(this->hmac)];
|
||||
|
||||
|
||||
this->hmac->get_mac(this->hmac, data, mac);
|
||||
|
||||
|
||||
if (signature.len != this->block_size)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -142,7 +142,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
|
||||
private_hmac_signer_t *this;
|
||||
size_t trunc;
|
||||
hash_algorithm_t hash;
|
||||
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case AUTH_HMAC_SHA1_96:
|
||||
@@ -180,7 +180,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_hmac_signer_t);
|
||||
this->hmac = hmac_create(hash);
|
||||
if (this->hmac == NULL)
|
||||
@@ -190,7 +190,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
|
||||
}
|
||||
/* prevent invalid truncation */
|
||||
this->block_size = min(trunc, this->hmac->get_block_size(this->hmac));
|
||||
|
||||
|
||||
/* interface functions */
|
||||
this->public.signer_interface.get_signature = (void (*) (signer_t*, chunk_t, u_int8_t*))get_signature;
|
||||
this->public.signer_interface.allocate_signature = (void (*) (signer_t*, chunk_t, chunk_t*))allocate_signature;
|
||||
@@ -199,7 +199,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
|
||||
this->public.signer_interface.get_block_size = (size_t (*) (signer_t*))get_block_size;
|
||||
this->public.signer_interface.set_key = (void (*) (signer_t*,chunk_t))set_key;
|
||||
this->public.signer_interface.destroy = (void (*) (signer_t*))destroy;
|
||||
|
||||
|
||||
return &(this->public);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ typedef struct hmac_signer_t hmac_signer_t;
|
||||
* HMAC uses a standard hash function implemented in a hasher_t to build a MAC.
|
||||
*/
|
||||
struct hmac_signer_t {
|
||||
|
||||
|
||||
/**
|
||||
* generic signer_t interface for this signer
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,7 @@ struct private_ldap_fetcher_t {
|
||||
* Public data
|
||||
*/
|
||||
ldap_fetcher_t public;
|
||||
|
||||
|
||||
/**
|
||||
* timeout to use for fetches
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ static bool parse(LDAP *ldap, LDAPMessage *result, chunk_t *response)
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1("getting LDAP values failed: %s",
|
||||
DBG1("getting LDAP values failed: %s",
|
||||
ldap_err2string(ldap_result2error(ldap, entry, 0)));
|
||||
}
|
||||
ldap_memfree(attr);
|
||||
@@ -110,7 +110,7 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
|
||||
int ldap_version = LDAP_VERSION3;
|
||||
struct timeval timeout;
|
||||
status_t status = FAILED;
|
||||
|
||||
|
||||
if (!strneq(url, "ldap", 4))
|
||||
{
|
||||
return NOT_SUPPORTED;
|
||||
@@ -126,7 +126,7 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
|
||||
ldap_free_urldesc(lurl);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
||||
timeout.tv_sec = this->timeout;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
@@ -171,7 +171,7 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
|
||||
static bool set_option(private_ldap_fetcher_t *this, fetcher_option_t option, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, option);
|
||||
switch (option)
|
||||
{
|
||||
@@ -203,9 +203,9 @@ ldap_fetcher_t *ldap_fetcher_create()
|
||||
this->public.interface.fetch = (status_t(*)(fetcher_t*,char*,chunk_t*))fetch;
|
||||
this->public.interface.set_option = (bool(*)(fetcher_t*, fetcher_option_t option, ...))set_option;
|
||||
this->public.interface.destroy = (void (*)(fetcher_t*))destroy;
|
||||
|
||||
|
||||
this->timeout = DEFAULT_TIMEOUT;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ struct private_ldap_plugin_t {
|
||||
*/
|
||||
static void destroy(private_ldap_plugin_t *this)
|
||||
{
|
||||
lib->fetcher->remove_fetcher(lib->fetcher,
|
||||
lib->fetcher->remove_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)ldap_fetcher_create);
|
||||
free(this);
|
||||
}
|
||||
@@ -47,14 +47,14 @@ static void destroy(private_ldap_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_ldap_plugin_t *this = malloc_thing(private_ldap_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)ldap_fetcher_create, "ldap://");
|
||||
lib->fetcher->add_fetcher(lib->fetcher,
|
||||
(fetcher_constructor_t)ldap_fetcher_create, "ldaps://");
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
* Copyright (C) 2005-2006 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* Copyright (C) 1990-1992, RSA Data Security, Inc. Created 1990.
|
||||
* Copyright (C) 1990-1992, RSA Data Security, Inc. Created 1990.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm.
|
||||
* Ported to fulfill hasher_t interface.
|
||||
*
|
||||
@@ -83,7 +83,7 @@ struct private_md4_hasher_t {
|
||||
* Public interface for this hasher.
|
||||
*/
|
||||
md4_hasher_t public;
|
||||
|
||||
|
||||
/*
|
||||
* State of the hasher.
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ static void Encode (u_int8_t *output, u_int32_t *input, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
{
|
||||
output[j] = (u_int8_t)(input[i] & 0xff);
|
||||
output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
|
||||
@@ -220,7 +220,7 @@ static void MD4Update(private_md4_hasher_t *this, u_int8_t *input, size_t inputL
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible. */
|
||||
if (inputLen >= partLen)
|
||||
if (inputLen >= partLen)
|
||||
{
|
||||
memcpy(&this->buffer[index], input, partLen);
|
||||
MD4Transform (this->state, this->buffer);
|
||||
@@ -288,7 +288,7 @@ static void get_hash(private_md4_hasher_t *this, chunk_t chunk, u_int8_t *buffer
|
||||
static void allocate_hash(private_md4_hasher_t *this, chunk_t chunk, chunk_t *hash)
|
||||
{
|
||||
chunk_t allocated_hash;
|
||||
|
||||
|
||||
MD4Update(this, chunk.ptr, chunk.len);
|
||||
if (hash != NULL)
|
||||
{
|
||||
@@ -297,11 +297,11 @@ static void allocate_hash(private_md4_hasher_t *this, chunk_t chunk, chunk_t *ha
|
||||
|
||||
MD4Final(this, allocated_hash.ptr);
|
||||
this->public.hasher_interface.reset(&(this->public.hasher_interface));
|
||||
|
||||
|
||||
*hash = allocated_hash;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of hasher_t.get_hash_size.
|
||||
*/
|
||||
@@ -337,21 +337,21 @@ static void destroy(private_md4_hasher_t *this)
|
||||
md4_hasher_t *md4_hasher_create(hash_algorithm_t algo)
|
||||
{
|
||||
private_md4_hasher_t *this;
|
||||
|
||||
|
||||
if (algo != HASH_MD4)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
this = malloc_thing(private_md4_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;
|
||||
|
||||
|
||||
/* initialize */
|
||||
reset(this);
|
||||
|
||||
|
||||
return &(this->public);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct md4_hasher_t md4_hasher_t;
|
||||
* Implementation of hasher_t interface using the MD4 algorithm.
|
||||
*/
|
||||
struct md4_hasher_t {
|
||||
|
||||
|
||||
/**
|
||||
* Generic hasher_t interface for this hasher.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ struct md4_hasher_t {
|
||||
|
||||
/**
|
||||
* Creates a new md4_hasher_t.
|
||||
*
|
||||
*
|
||||
* @param algo hash algorithm, must be HASH_MD4
|
||||
* @return md4_hasher_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -47,12 +47,12 @@ static void destroy(private_md4_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_md4_plugin_t *this = malloc_thing(private_md4_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->crypto->add_hasher(lib->crypto, HASH_MD4,
|
||||
(hasher_constructor_t)md4_hasher_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
* Copyright (C) 2005-2006 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991.
|
||||
* Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
|
||||
* Ported to fulfill hasher_t interface.
|
||||
*
|
||||
@@ -50,7 +50,7 @@ static u_int8_t PADDING[64] = {
|
||||
|
||||
/*
|
||||
* ugly macro stuff
|
||||
*/
|
||||
*/
|
||||
/* F, G, H and I are basic MD5 functions.
|
||||
*/
|
||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
@@ -98,7 +98,7 @@ struct private_md5_hasher_t {
|
||||
* Public interface for this hasher.
|
||||
*/
|
||||
md5_hasher_t public;
|
||||
|
||||
|
||||
/*
|
||||
* State of the hasher.
|
||||
*/
|
||||
@@ -117,7 +117,7 @@ static void Encode (u_int8_t *output, u_int32_t *input, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
{
|
||||
output[j] = (u_int8_t)(input[i] & 0xff);
|
||||
output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
|
||||
@@ -253,7 +253,7 @@ static void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputL
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible. */
|
||||
if (inputLen >= partLen)
|
||||
if (inputLen >= partLen)
|
||||
{
|
||||
memcpy(&this->buffer[index], input, partLen);
|
||||
MD5Transform (this->state, this->buffer);
|
||||
@@ -321,7 +321,7 @@ static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer
|
||||
static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
|
||||
{
|
||||
chunk_t allocated_hash;
|
||||
|
||||
|
||||
MD5Update(this, chunk.ptr, chunk.len);
|
||||
if (hash != NULL)
|
||||
{
|
||||
@@ -330,11 +330,11 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
|
||||
|
||||
MD5Final(this, allocated_hash.ptr);
|
||||
this->public.hasher_interface.reset(&(this->public.hasher_interface));
|
||||
|
||||
|
||||
*hash = allocated_hash;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of hasher_t.get_hash_size.
|
||||
*/
|
||||
@@ -370,21 +370,21 @@ static void destroy(private_md5_hasher_t *this)
|
||||
md5_hasher_t *md5_hasher_create(hash_algorithm_t algo)
|
||||
{
|
||||
private_md5_hasher_t *this;
|
||||
|
||||
|
||||
if (algo != HASH_MD5)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
this = malloc_thing(private_md5_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;
|
||||
|
||||
|
||||
/* initialize */
|
||||
reset(this);
|
||||
|
||||
|
||||
return &(this->public);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct md5_hasher_t md5_hasher_t;
|
||||
* Implementation of hasher_t interface using the MD5 algorithm.
|
||||
*/
|
||||
struct md5_hasher_t {
|
||||
|
||||
|
||||
/**
|
||||
* Generic hasher_t interface for this hasher.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ struct md5_hasher_t {
|
||||
|
||||
/**
|
||||
* Creates a new md5_hasher_t.
|
||||
*
|
||||
*
|
||||
* @param algo hash algorithm, must be HASH_MD5
|
||||
* @return md5_hasher_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -47,12 +47,12 @@ static void destroy(private_md5_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_md5_plugin_t *this = malloc_thing(private_md5_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->crypto->add_hasher(lib->crypto, HASH_MD5,
|
||||
(hasher_constructor_t)md5_hasher_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,37 +42,37 @@ struct private_mysql_database_t {
|
||||
* public functions
|
||||
*/
|
||||
mysql_database_t public;
|
||||
|
||||
|
||||
/**
|
||||
* connection pool, contains conn_t
|
||||
*/
|
||||
linked_list_t *pool;
|
||||
|
||||
|
||||
/**
|
||||
* mutex to lock pool
|
||||
*/
|
||||
mutex_t *mutex;
|
||||
|
||||
|
||||
/**
|
||||
* hostname to connect to
|
||||
*/
|
||||
char *host;
|
||||
|
||||
|
||||
/**
|
||||
* username to use
|
||||
*/
|
||||
char *username;
|
||||
|
||||
|
||||
/**
|
||||
* password
|
||||
*/
|
||||
char *password;
|
||||
|
||||
|
||||
/**
|
||||
* database name
|
||||
*/
|
||||
char *database;
|
||||
|
||||
|
||||
/**
|
||||
* tcp port
|
||||
*/
|
||||
@@ -85,12 +85,12 @@ typedef struct conn_t conn_t;
|
||||
* connection pool entry
|
||||
*/
|
||||
struct conn_t {
|
||||
|
||||
|
||||
/**
|
||||
* MySQL database connection
|
||||
*/
|
||||
MYSQL *mysql;
|
||||
|
||||
|
||||
/**
|
||||
* connection in use?
|
||||
*/
|
||||
@@ -164,9 +164,9 @@ static conn_t *conn_get(private_mysql_database_t *this)
|
||||
{
|
||||
conn_t *current, *found = NULL;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
thread_initialize();
|
||||
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
this->mutex->lock(this->mutex);
|
||||
@@ -231,7 +231,7 @@ static MYSQL_STMT* run(MYSQL *mysql, char *sql, va_list *args)
|
||||
{
|
||||
MYSQL_STMT *stmt;
|
||||
int params;
|
||||
|
||||
|
||||
stmt = mysql_stmt_init(mysql);
|
||||
if (stmt == NULL)
|
||||
{
|
||||
@@ -249,10 +249,10 @@ static MYSQL_STMT* run(MYSQL *mysql, char *sql, va_list *args)
|
||||
{
|
||||
int i;
|
||||
MYSQL_BIND *bind;
|
||||
|
||||
|
||||
bind = alloca(sizeof(MYSQL_BIND) * params);
|
||||
memset(bind, 0, sizeof(MYSQL_BIND) * params);
|
||||
|
||||
|
||||
for (i = 0; i < params; i++)
|
||||
{
|
||||
switch (va_arg(*args, db_type_t))
|
||||
@@ -285,7 +285,7 @@ static MYSQL_STMT* run(MYSQL *mysql, char *sql, va_list *args)
|
||||
break;
|
||||
}
|
||||
case DB_BLOB:
|
||||
{
|
||||
{
|
||||
chunk_t chunk = va_arg(*args, chunk_t);
|
||||
bind[i].buffer_type = MYSQL_TYPE_BLOB;
|
||||
bind[i].buffer = chunk.ptr;
|
||||
@@ -353,9 +353,9 @@ typedef struct {
|
||||
static void mysql_enumerator_destroy(mysql_enumerator_t *this)
|
||||
{
|
||||
int columns, i;
|
||||
|
||||
|
||||
columns = mysql_stmt_field_count(this->stmt);
|
||||
|
||||
|
||||
for (i = 0; i < columns; i++)
|
||||
{
|
||||
switch (this->bind[i].buffer_type)
|
||||
@@ -385,9 +385,9 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
|
||||
{
|
||||
int i, columns;
|
||||
va_list args;
|
||||
|
||||
|
||||
columns = mysql_stmt_field_count(this->stmt);
|
||||
|
||||
|
||||
/* free/reset data set of previous call */
|
||||
for (i = 0; i < columns; i++)
|
||||
{
|
||||
@@ -419,7 +419,7 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
|
||||
DBG1("fetching MySQL row failed: %s", mysql_stmt_error(this->stmt));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
va_start(args, this);
|
||||
for (i = 0; i < columns; i++)
|
||||
{
|
||||
@@ -481,7 +481,7 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
|
||||
va_list args;
|
||||
mysql_enumerator_t *enumerator = NULL;
|
||||
conn_t *conn;
|
||||
|
||||
|
||||
conn = conn_get(this);
|
||||
if (!conn)
|
||||
{
|
||||
@@ -493,7 +493,7 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
|
||||
if (stmt)
|
||||
{
|
||||
int columns, i;
|
||||
|
||||
|
||||
enumerator = malloc_thing(mysql_enumerator_t);
|
||||
enumerator->public.enumerate = (void*)mysql_enumerator_enumerate;
|
||||
enumerator->public.destroy = (void*)mysql_enumerator_destroy;
|
||||
@@ -527,7 +527,7 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
|
||||
break;
|
||||
}
|
||||
case DB_BLOB:
|
||||
{
|
||||
{
|
||||
enumerator->bind[i].buffer_type = MYSQL_TYPE_BLOB;
|
||||
enumerator->bind[i].length = &enumerator->length[i];
|
||||
break;
|
||||
@@ -569,7 +569,7 @@ static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...)
|
||||
va_list args;
|
||||
conn_t *conn;
|
||||
int affected = -1;
|
||||
|
||||
|
||||
conn = conn_get(this);
|
||||
if (!conn)
|
||||
{
|
||||
@@ -590,7 +590,7 @@ static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...)
|
||||
conn_release(conn);
|
||||
return affected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of database_t.get_driver
|
||||
*/
|
||||
@@ -646,7 +646,7 @@ static bool parse_uri(private_mysql_database_t *this, char *uri)
|
||||
{
|
||||
*pos = '\0';
|
||||
database = pos + 1;
|
||||
|
||||
|
||||
this->host = strdup(host);
|
||||
this->username = strdup(username);
|
||||
this->password = strdup(password);
|
||||
@@ -668,19 +668,19 @@ mysql_database_t *mysql_database_create(char *uri)
|
||||
{
|
||||
conn_t *conn;
|
||||
private_mysql_database_t *this;
|
||||
|
||||
|
||||
if (!strneq(uri, "mysql://", 8))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
this = malloc_thing(private_mysql_database_t);
|
||||
|
||||
|
||||
this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query;
|
||||
this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute;
|
||||
this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver;
|
||||
this->public.db.destroy = (void(*)(database_t*))destroy;
|
||||
|
||||
|
||||
if (!parse_uri(this, uri))
|
||||
{
|
||||
free(this);
|
||||
@@ -688,7 +688,7 @@ mysql_database_t *mysql_database_create(char *uri)
|
||||
}
|
||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
||||
this->pool = linked_list_create();
|
||||
|
||||
|
||||
/* check connectivity */
|
||||
conn = conn_get(this);
|
||||
if (!conn)
|
||||
|
||||
@@ -49,16 +49,16 @@ static void destroy(private_mysql_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_mysql_plugin_t *this;
|
||||
|
||||
|
||||
if (!mysql_database_init())
|
||||
{
|
||||
DBG1("MySQL client library initialization failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_mysql_plugin_t);
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->db->add_database(lib->db,
|
||||
(database_constructor_t)mysql_database_create);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* 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
|
||||
@@ -23,17 +23,17 @@ typedef struct private_openssl_crypter_t private_openssl_crypter_t;
|
||||
* Private data of openssl_crypter_t
|
||||
*/
|
||||
struct private_openssl_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
openssl_crypter_t public;
|
||||
|
||||
|
||||
/*
|
||||
* the key
|
||||
*/
|
||||
chunk_t key;
|
||||
|
||||
|
||||
/*
|
||||
* the cipher to use
|
||||
*/
|
||||
@@ -49,17 +49,17 @@ typedef struct {
|
||||
* Identifier specified in IKEv2
|
||||
*/
|
||||
int ikev2_id;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the algorithm, as used in OpenSSL
|
||||
*/
|
||||
char *name;
|
||||
|
||||
|
||||
/**
|
||||
* Minimum valid key length in bytes
|
||||
*/
|
||||
size_t key_size_min;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum valid key length in bytes
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ static openssl_algorithm_t encryption_algs[] = {
|
||||
/**
|
||||
* Look up an OpenSSL algorithm name and validate its key size
|
||||
*/
|
||||
static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
|
||||
static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
|
||||
u_int16_t ikev2_algo, size_t *key_size)
|
||||
{
|
||||
while (openssl_algo->ikev2_id != END_OF_LIST)
|
||||
@@ -104,7 +104,7 @@ static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
|
||||
{
|
||||
*key_size = openssl_algo->key_size_min;
|
||||
}
|
||||
|
||||
|
||||
/* validate key size */
|
||||
if (*key_size < openssl_algo->key_size_min ||
|
||||
*key_size > openssl_algo->key_size_max)
|
||||
@@ -123,7 +123,7 @@ static void crypt(private_openssl_crypter_t *this, chunk_t data,
|
||||
{
|
||||
int len;
|
||||
u_char *out;
|
||||
|
||||
|
||||
out = data.ptr;
|
||||
if (dst)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ static void crypt(private_openssl_crypter_t *this, chunk_t data,
|
||||
/**
|
||||
* Implementation of crypter_t.decrypt.
|
||||
*/
|
||||
static void decrypt(private_openssl_crypter_t *this, chunk_t data,
|
||||
static void decrypt(private_openssl_crypter_t *this, chunk_t data,
|
||||
chunk_t iv, chunk_t *dst)
|
||||
{
|
||||
crypt(this, data, iv, dst, 0);
|
||||
@@ -154,7 +154,7 @@ static void decrypt(private_openssl_crypter_t *this, chunk_t data,
|
||||
/**
|
||||
* Implementation of crypter_t.encrypt.
|
||||
*/
|
||||
static void encrypt (private_openssl_crypter_t *this, chunk_t data,
|
||||
static void encrypt (private_openssl_crypter_t *this, chunk_t data,
|
||||
chunk_t iv, chunk_t *dst)
|
||||
{
|
||||
crypt(this, data, iv, dst, 1);
|
||||
@@ -196,13 +196,13 @@ static void destroy (private_openssl_crypter_t *this)
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
|
||||
openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
|
||||
size_t key_size)
|
||||
{
|
||||
private_openssl_crypter_t *this;
|
||||
|
||||
|
||||
this = malloc_thing(private_openssl_crypter_t);
|
||||
|
||||
|
||||
switch (algo)
|
||||
{
|
||||
case ENCR_NULL:
|
||||
@@ -218,7 +218,7 @@ openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
|
||||
this->cipher = EVP_get_cipherbyname("aes192");
|
||||
break;
|
||||
case 32: /* AES-256 */
|
||||
this->cipher = EVP_get_cipherbyname("aes256");
|
||||
this->cipher = EVP_get_cipherbyname("aes256");
|
||||
break;
|
||||
default:
|
||||
free(this);
|
||||
@@ -235,7 +235,7 @@ openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
|
||||
this->cipher = EVP_get_cipherbyname("camellia192");
|
||||
break;
|
||||
case 32: /* CAMELLIA 256 */
|
||||
this->cipher = EVP_get_cipherbyname("camellia256");
|
||||
this->cipher = EVP_get_cipherbyname("camellia256");
|
||||
break;
|
||||
default:
|
||||
free(this);
|
||||
@@ -258,22 +258,22 @@ openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!this->cipher)
|
||||
{
|
||||
/* OpenSSL does not support the requested 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;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct openssl_crypter_t openssl_crypter_t;
|
||||
* Implementation of crypters using OpenSSL.
|
||||
*/
|
||||
struct openssl_crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* The crypter_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct openssl_crypter_t {
|
||||
|
||||
/**
|
||||
* Constructor to create openssl_crypter_t.
|
||||
*
|
||||
*
|
||||
* @param algo algorithm to implement
|
||||
* @param key_size key size in bytes
|
||||
* @return openssl_crypter_t, NULL if not supported
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
typedef struct modulus_entry_t modulus_entry_t;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Entry of the modulus list.
|
||||
*/
|
||||
struct modulus_entry_t {
|
||||
@@ -30,20 +30,20 @@ struct modulus_entry_t {
|
||||
* Group number as it is defined in file transform_substructure.h.
|
||||
*/
|
||||
diffie_hellman_group_t group;
|
||||
|
||||
|
||||
/**
|
||||
* Pointer to the function to get the modulus.
|
||||
*/
|
||||
BIGNUM *(*get_prime)(BIGNUM *bn);
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Optimum length of exponent in bits.
|
||||
*/
|
||||
*/
|
||||
long opt_exponent_len;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Generator value.
|
||||
*/
|
||||
*/
|
||||
u_int16_t generator;
|
||||
};
|
||||
|
||||
@@ -71,27 +71,27 @@ struct private_openssl_diffie_hellman_t {
|
||||
* Public openssl_diffie_hellman_t interface.
|
||||
*/
|
||||
openssl_diffie_hellman_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
u_int16_t group;
|
||||
|
||||
|
||||
/**
|
||||
* Diffie Hellman object
|
||||
*/
|
||||
DH *dh;
|
||||
|
||||
|
||||
/**
|
||||
* Other public value
|
||||
*/
|
||||
BIGNUM *pub_key;
|
||||
|
||||
|
||||
/**
|
||||
* Shared secret
|
||||
*/
|
||||
chunk_t shared_secret;
|
||||
|
||||
|
||||
/**
|
||||
* True if shared secret is computed
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ static status_t get_shared_secret(private_openssl_diffie_hellman_t *this,
|
||||
/* shared secret should requires a len according the DH group */
|
||||
*secret = chunk_alloc(DH_size(this->dh));
|
||||
memset(secret->ptr, 0, secret->len);
|
||||
memcpy(secret->ptr + secret->len - this->shared_secret.len,
|
||||
memcpy(secret->ptr + secret->len - this->shared_secret.len,
|
||||
this->shared_secret.ptr, this->shared_secret.len);
|
||||
|
||||
return SUCCESS;
|
||||
@@ -137,7 +137,7 @@ static void set_other_public_value(private_openssl_diffie_hellman_t *this,
|
||||
chunk_t value)
|
||||
{
|
||||
int len;
|
||||
|
||||
|
||||
BN_bin2bn(value.ptr, value.len, this->pub_key);
|
||||
chunk_clear(&this->shared_secret);
|
||||
this->shared_secret.ptr = malloc(DH_size(this->dh));
|
||||
@@ -167,10 +167,10 @@ static status_t set_modulus(private_openssl_diffie_hellman_t *this)
|
||||
{
|
||||
int i;
|
||||
bool ansi_x9_42;
|
||||
|
||||
|
||||
ansi_x9_42 = lib->settings->get_bool(lib->settings,
|
||||
"libstrongswan.dh_exponent_ansi_x9_42", TRUE);
|
||||
|
||||
|
||||
for (i = 0; i < (sizeof(modulus_entries) / sizeof(modulus_entry_t)); i++)
|
||||
{
|
||||
if (modulus_entries[i].group == this->group)
|
||||
@@ -205,32 +205,32 @@ static void destroy(private_openssl_diffie_hellman_t *this)
|
||||
openssl_diffie_hellman_t *openssl_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
{
|
||||
private_openssl_diffie_hellman_t *this = malloc_thing(private_openssl_diffie_hellman_t);
|
||||
|
||||
|
||||
this->public.dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
|
||||
this->public.dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
|
||||
this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
|
||||
this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
|
||||
this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
|
||||
|
||||
|
||||
this->dh = DH_new();
|
||||
if (!this->dh)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this->group = group;
|
||||
this->computed = FALSE;
|
||||
this->pub_key = BN_new();
|
||||
this->shared_secret = chunk_empty;
|
||||
|
||||
|
||||
/* find a modulus according to group */
|
||||
if (set_modulus(this) != SUCCESS)
|
||||
{
|
||||
destroy(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* generate my public and private values */
|
||||
if (!DH_generate_key(this->dh))
|
||||
{
|
||||
@@ -238,6 +238,6 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(diffie_hellman_group_t g
|
||||
return NULL;
|
||||
}
|
||||
DBG2("size of DH secret exponent: %d bits", BN_num_bits(this->dh->priv_key));
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct openssl_diffie_hellman_t openssl_diffie_hellman_t;
|
||||
* Implementation of the Diffie-Hellman algorithm using OpenSSL.
|
||||
*/
|
||||
struct openssl_diffie_hellman_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct openssl_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Creates a new openssl_diffie_hellman_t object.
|
||||
*
|
||||
*
|
||||
* @param group Diffie Hellman group number to use
|
||||
* @return openssl_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -31,27 +31,27 @@ struct private_openssl_ec_diffie_hellman_t {
|
||||
* Public openssl_ec_diffie_hellman_t interface.
|
||||
*/
|
||||
openssl_ec_diffie_hellman_t public;
|
||||
|
||||
|
||||
/**
|
||||
* Diffie Hellman group number.
|
||||
*/
|
||||
u_int16_t group;
|
||||
|
||||
|
||||
/**
|
||||
* EC private (public) key
|
||||
*/
|
||||
EC_KEY *key;
|
||||
|
||||
|
||||
/**
|
||||
* EC group
|
||||
*/
|
||||
const EC_GROUP *ec_group;
|
||||
|
||||
|
||||
/**
|
||||
* Other public key
|
||||
*/
|
||||
EC_POINT *pub_key;
|
||||
|
||||
|
||||
/**
|
||||
* Shared secret
|
||||
*/
|
||||
@@ -72,13 +72,13 @@ static bool chunk2ecp(const EC_GROUP *group, chunk_t chunk, EC_POINT *point)
|
||||
BN_CTX *ctx;
|
||||
BIGNUM *x, *y;
|
||||
bool ret = FALSE;
|
||||
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (!ctx)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
x = BN_CTX_get(ctx);
|
||||
y = BN_CTX_get(ctx);
|
||||
@@ -86,17 +86,17 @@ static bool chunk2ecp(const EC_GROUP *group, chunk_t chunk, EC_POINT *point)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!openssl_bn_split(chunk, x, y))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
ret = TRUE;
|
||||
error:
|
||||
BN_CTX_end(ctx);
|
||||
@@ -114,13 +114,13 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
|
||||
BN_CTX *ctx;
|
||||
BIGNUM *x, *y;
|
||||
bool ret = FALSE;
|
||||
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (!ctx)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
x = BN_CTX_get(ctx);
|
||||
y = BN_CTX_get(ctx);
|
||||
@@ -128,12 +128,12 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (x_coordinate_only)
|
||||
{
|
||||
y = NULL;
|
||||
@@ -142,7 +142,7 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
ret = TRUE;
|
||||
error:
|
||||
BN_CTX_end(ctx);
|
||||
@@ -152,7 +152,7 @@ error:
|
||||
|
||||
/**
|
||||
* Compute the shared secret.
|
||||
*
|
||||
*
|
||||
* We cannot use the function ECDH_compute_key() because that returns only the
|
||||
* x coordinate of the shared secret point (which is defined, for instance, in
|
||||
* 'NIST SP 800-56A').
|
||||
@@ -166,13 +166,13 @@ static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this, chunk_
|
||||
const BIGNUM *priv_key;
|
||||
EC_POINT *secret = NULL;
|
||||
bool x_coordinate_only, ret = FALSE;
|
||||
|
||||
|
||||
priv_key = EC_KEY_get0_private_key(this->key);
|
||||
if (!priv_key)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
secret = EC_POINT_new(this->ec_group);
|
||||
if (!secret)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this, chunk_
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The default setting ecp_x_coordinate_only = TRUE
|
||||
* applies the following errata for RFC 4753:
|
||||
@@ -195,7 +195,7 @@ static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this, chunk_
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
ret = TRUE;
|
||||
error:
|
||||
if (secret)
|
||||
@@ -215,14 +215,14 @@ static void set_other_public_value(private_openssl_ec_diffie_hellman_t *this, ch
|
||||
DBG1("ECDH public value is malformed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
chunk_free(&this->shared_secret);
|
||||
|
||||
|
||||
if (!compute_shared_key(this, &this->shared_secret)) {
|
||||
DBG1("ECDH shared secret computation failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this->computed = TRUE;
|
||||
}
|
||||
|
||||
@@ -272,13 +272,13 @@ static void destroy(private_openssl_ec_diffie_hellman_t *this)
|
||||
openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_group_t group)
|
||||
{
|
||||
private_openssl_ec_diffie_hellman_t *this = malloc_thing(private_openssl_ec_diffie_hellman_t);
|
||||
|
||||
|
||||
this->public.dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
|
||||
this->public.dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
|
||||
this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
|
||||
this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
|
||||
this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
|
||||
|
||||
|
||||
switch (group)
|
||||
{
|
||||
case ECP_192_BIT:
|
||||
@@ -300,34 +300,34 @@ openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_gro
|
||||
this->key = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!this->key)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* caching the EC group */
|
||||
this->ec_group = EC_KEY_get0_group(this->key);
|
||||
|
||||
|
||||
this->pub_key = EC_POINT_new(this->ec_group);
|
||||
if (!this->pub_key)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* generate an EC private (public) key */
|
||||
if (!EC_KEY_generate_key(this->key))
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this->group = group;
|
||||
this->computed = FALSE;
|
||||
|
||||
|
||||
this->shared_secret = chunk_empty;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct openssl_ec_diffie_hellman_t openssl_ec_diffie_hellman_t;
|
||||
* Implementation of the EC Diffie-Hellman algorithm using OpenSSL.
|
||||
*/
|
||||
struct openssl_ec_diffie_hellman_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements diffie_hellman_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct openssl_ec_diffie_hellman_t {
|
||||
|
||||
/**
|
||||
* Creates a new openssl_ec_diffie_hellman_t object.
|
||||
*
|
||||
*
|
||||
* @param group EC Diffie Hellman group number to use
|
||||
* @return openssl_ec_diffie_hellman_t object, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -34,12 +34,12 @@ struct private_openssl_ec_private_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
openssl_ec_private_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* EC key object
|
||||
*/
|
||||
EC_KEY *ec;
|
||||
|
||||
|
||||
/**
|
||||
* reference count
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ static bool build_signature(private_openssl_ec_private_key_t *this,
|
||||
{
|
||||
bool built = FALSE;
|
||||
ECDSA_SIG *sig;
|
||||
|
||||
|
||||
sig = ECDSA_do_sign(hash.ptr, hash.len, this->ec);
|
||||
if (sig)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ static bool build_curve_signature(private_openssl_ec_private_key_t *this,
|
||||
EC_GROUP *req_group;
|
||||
chunk_t hash;
|
||||
bool built;
|
||||
|
||||
|
||||
req_group = EC_GROUP_new_by_curve_name(nid_curve);
|
||||
if (!req_group)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ static bool build_der_signature(private_openssl_ec_private_key_t *this,
|
||||
chunk_t hash, sig;
|
||||
int siglen = 0;
|
||||
bool built;
|
||||
|
||||
|
||||
if (!openssl_hash_chunk(hash_nid, data, &hash))
|
||||
{
|
||||
return FALSE;
|
||||
@@ -153,7 +153,7 @@ static bool sign(private_openssl_ec_private_key_t *this,
|
||||
case SIGN_ECDSA_WITH_SHA512_DER:
|
||||
return build_der_signature(this, NID_sha512, data, signature);
|
||||
case SIGN_ECDSA_256:
|
||||
return build_curve_signature(this, scheme, NID_sha256,
|
||||
return build_curve_signature(this, scheme, NID_sha256,
|
||||
NID_X9_62_prime256v1, data, signature);
|
||||
case SIGN_ECDSA_384:
|
||||
return build_curve_signature(this, scheme, NID_sha384,
|
||||
@@ -202,11 +202,11 @@ static public_key_t* get_public_key(private_openssl_ec_private_key_t *this)
|
||||
public_key_t *public;
|
||||
chunk_t key;
|
||||
u_char *p;
|
||||
|
||||
|
||||
key = chunk_alloc(i2d_EC_PUBKEY(this->ec, NULL));
|
||||
p = key.ptr;
|
||||
i2d_EC_PUBKEY(this->ec, &p);
|
||||
|
||||
|
||||
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ECDSA,
|
||||
BUILD_BLOB_ASN1_DER, key, BUILD_END);
|
||||
free(key.ptr);
|
||||
@@ -229,7 +229,7 @@ static bool get_encoding(private_openssl_ec_private_key_t *this,
|
||||
key_encoding_type_t type, chunk_t *encoding)
|
||||
{
|
||||
u_char *p;
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case KEY_PRIV_ASN1_DER:
|
||||
@@ -275,7 +275,7 @@ static void destroy(private_openssl_ec_private_key_t *this)
|
||||
static private_openssl_ec_private_key_t *create_empty(void)
|
||||
{
|
||||
private_openssl_ec_private_key_t *this = malloc_thing(private_openssl_ec_private_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
|
||||
this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
|
||||
this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
|
||||
@@ -287,10 +287,10 @@ static private_openssl_ec_private_key_t *create_empty(void)
|
||||
this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
|
||||
|
||||
|
||||
this->ec = NULL;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ static private_openssl_ec_private_key_t *create_empty(void)
|
||||
static openssl_ec_private_key_t *generate(size_t key_size)
|
||||
{
|
||||
private_openssl_ec_private_key_t *this = create_empty();
|
||||
|
||||
|
||||
switch (key_size)
|
||||
{
|
||||
case 256:
|
||||
@@ -335,9 +335,9 @@ static openssl_ec_private_key_t *generate(size_t key_size)
|
||||
static openssl_ec_private_key_t *load(chunk_t blob)
|
||||
{
|
||||
private_openssl_ec_private_key_t *this = create_empty();
|
||||
|
||||
|
||||
this->ec = d2i_ECPrivateKey(NULL, (const u_char**)&blob.ptr, blob.len);
|
||||
|
||||
|
||||
if (!this->ec)
|
||||
{
|
||||
destroy(this);
|
||||
@@ -369,7 +369,7 @@ struct private_builder_t {
|
||||
static openssl_ec_private_key_t *build(private_builder_t *this)
|
||||
{
|
||||
openssl_ec_private_key_t *key = this->key;
|
||||
|
||||
|
||||
free(this);
|
||||
return key;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
if (!this->key)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_KEY_SIZE:
|
||||
@@ -416,18 +416,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *openssl_ec_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_ECDSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ struct private_openssl_ec_public_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
openssl_ec_public_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* EC key object
|
||||
*/
|
||||
EC_KEY *ec;
|
||||
|
||||
|
||||
/**
|
||||
* reference counter
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ static bool verify_signature(private_openssl_ec_public_key_t *this,
|
||||
{
|
||||
bool valid = FALSE;
|
||||
ECDSA_SIG *sig;
|
||||
|
||||
|
||||
sig = ECDSA_SIG_new();
|
||||
if (sig)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ static bool verify_curve_signature(private_openssl_ec_public_key_t *this,
|
||||
EC_GROUP *req_group;
|
||||
chunk_t hash;
|
||||
bool valid;
|
||||
|
||||
|
||||
req_group = EC_GROUP_new_by_curve_name(nid_curve);
|
||||
if (!req_group)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ static bool verify_der_signature(private_openssl_ec_public_key_t *this,
|
||||
{
|
||||
chunk_t hash;
|
||||
bool valid = FALSE;
|
||||
|
||||
|
||||
/* remove any preceding 0-bytes from signature */
|
||||
while (signature.len && signature.ptr[0] == 0x00)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ bool openssl_ec_fingerprint(EC_KEY *ec, key_encoding_type_t type, chunk_t *fp)
|
||||
hasher_t *hasher;
|
||||
chunk_t key;
|
||||
u_char *p;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, ec, fp))
|
||||
{
|
||||
return TRUE;
|
||||
@@ -244,7 +244,7 @@ static bool get_encoding(private_openssl_ec_public_key_t *this,
|
||||
key_encoding_type_t type, chunk_t *encoding)
|
||||
{
|
||||
u_char *p;
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case KEY_PUB_SPKI_ASN1_DER:
|
||||
@@ -290,7 +290,7 @@ static void destroy(private_openssl_ec_public_key_t *this)
|
||||
static private_openssl_ec_public_key_t *create_empty()
|
||||
{
|
||||
private_openssl_ec_public_key_t *this = malloc_thing(private_openssl_ec_public_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(public_key_t *this))get_type;
|
||||
this->public.interface.verify = (bool (*)(public_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t signature))verify;
|
||||
this->public.interface.encrypt = (bool (*)(public_key_t *this, chunk_t crypto, chunk_t *plain))encrypt_;
|
||||
@@ -300,10 +300,10 @@ static private_openssl_ec_public_key_t *create_empty()
|
||||
this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (public_key_t* (*)(public_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(public_key_t *this))destroy;
|
||||
|
||||
|
||||
this->ec = NULL;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ static openssl_ec_public_key_t *load(chunk_t blob)
|
||||
{
|
||||
private_openssl_ec_public_key_t *this = create_empty();
|
||||
u_char *p = blob.ptr;
|
||||
|
||||
|
||||
this->ec = d2i_EC_PUBKEY(NULL, (const u_char**)&p, blob.len);
|
||||
|
||||
|
||||
if (!this->ec)
|
||||
{
|
||||
destroy(this);
|
||||
@@ -343,7 +343,7 @@ struct private_builder_t {
|
||||
static openssl_ec_public_key_t *build(private_builder_t *this)
|
||||
{
|
||||
openssl_ec_public_key_t *key = this->key;
|
||||
|
||||
|
||||
free(this);
|
||||
return key;
|
||||
}
|
||||
@@ -356,7 +356,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
if (!this->key)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_ASN1_DER:
|
||||
@@ -383,18 +383,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *openssl_ec_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_ECDSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* 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
|
||||
@@ -23,19 +23,19 @@ typedef struct private_openssl_hasher_t private_openssl_hasher_t;
|
||||
* Private data of openssl_hasher_t
|
||||
*/
|
||||
struct private_openssl_hasher_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public part of this class.
|
||||
*/
|
||||
openssl_hasher_t public;
|
||||
|
||||
|
||||
/**
|
||||
* the hasher to use
|
||||
*/
|
||||
const EVP_MD *hasher;
|
||||
|
||||
|
||||
/**
|
||||
* the current digest context
|
||||
* the current digest context
|
||||
*/
|
||||
EVP_MD_CTX *ctx;
|
||||
};
|
||||
@@ -49,7 +49,7 @@ typedef struct {
|
||||
* Identifier specified in IKEv2
|
||||
*/
|
||||
int ikev2_id;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the algorithm, as used in OpenSSL
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ static openssl_algorithm_t integrity_algs[] = {
|
||||
/**
|
||||
* Look up an OpenSSL algorithm name
|
||||
*/
|
||||
static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
|
||||
static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
|
||||
u_int16_t ikev2_algo)
|
||||
{
|
||||
while (openssl_algo->ikev2_id != END_OF_LIST)
|
||||
@@ -133,7 +133,7 @@ static void allocate_hash(private_openssl_hasher_t *this, chunk_t chunk,
|
||||
}
|
||||
else
|
||||
{
|
||||
get_hash(this, chunk, NULL);
|
||||
get_hash(this, chunk, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ static void destroy (private_openssl_hasher_t *this)
|
||||
openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
|
||||
{
|
||||
private_openssl_hasher_t *this;
|
||||
|
||||
|
||||
char* name = lookup_algorithm(integrity_algs, algo);
|
||||
if (!name)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
|
||||
}
|
||||
|
||||
this = malloc_thing(private_openssl_hasher_t);
|
||||
|
||||
|
||||
this->hasher = EVP_get_digestbyname(name);
|
||||
if (!this->hasher)
|
||||
{
|
||||
@@ -169,17 +169,17 @@ openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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->ctx = EVP_MD_CTX_create();
|
||||
|
||||
|
||||
/* initialization */
|
||||
reset(this);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct openssl_hasher_t openssl_hasher_t;
|
||||
* Implementation of hashers using OpenSSL.
|
||||
*/
|
||||
struct openssl_hasher_t {
|
||||
|
||||
|
||||
/**
|
||||
* The hasher_t interface.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct openssl_hasher_t {
|
||||
|
||||
/**
|
||||
* Constructor to create openssl_hasher_t.
|
||||
*
|
||||
*
|
||||
* @param algo algorithm
|
||||
* @return openssl_hasher_t, NULL if not supported
|
||||
*/
|
||||
|
||||
@@ -83,7 +83,7 @@ struct CRYPTO_dynlock_value {
|
||||
static struct CRYPTO_dynlock_value *create_function(const char *file, int line)
|
||||
{
|
||||
struct CRYPTO_dynlock_value *lock;
|
||||
|
||||
|
||||
lock = malloc_thing(struct CRYPTO_dynlock_value);
|
||||
lock->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
||||
return lock;
|
||||
@@ -132,11 +132,11 @@ static void threading_init()
|
||||
|
||||
CRYPTO_set_id_callback(id_function);
|
||||
CRYPTO_set_locking_callback(locking_function);
|
||||
|
||||
|
||||
CRYPTO_set_dynlock_create_callback(create_function);
|
||||
CRYPTO_set_dynlock_lock_callback(lock_function);
|
||||
CRYPTO_set_dynlock_destroy_callback(destroy_function);
|
||||
|
||||
|
||||
num_locks = CRYPTO_num_locks();
|
||||
mutex = malloc(sizeof(mutex_t*) * num_locks);
|
||||
for (i = 0; i < num_locks; i++)
|
||||
@@ -151,7 +151,7 @@ static void threading_init()
|
||||
static void threading_cleanup()
|
||||
{
|
||||
int i, num_locks;
|
||||
|
||||
|
||||
num_locks = CRYPTO_num_locks();
|
||||
for (i = 0; i < num_locks; i++)
|
||||
{
|
||||
@@ -170,9 +170,9 @@ static void destroy(private_openssl_plugin_t *this)
|
||||
(crypter_constructor_t)openssl_crypter_create);
|
||||
lib->crypto->remove_hasher(lib->crypto,
|
||||
(hasher_constructor_t)openssl_hasher_create);
|
||||
lib->crypto->remove_dh(lib->crypto,
|
||||
lib->crypto->remove_dh(lib->crypto,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->remove_dh(lib->crypto,
|
||||
lib->crypto->remove_dh(lib->crypto,
|
||||
(dh_constructor_t)openssl_ec_diffie_hellman_create);
|
||||
lib->creds->remove_builder(lib->creds,
|
||||
(builder_constructor_t)openssl_rsa_private_key_builder);
|
||||
@@ -182,13 +182,13 @@ static void destroy(private_openssl_plugin_t *this)
|
||||
(builder_constructor_t)openssl_ec_private_key_builder);
|
||||
lib->creds->remove_builder(lib->creds,
|
||||
(builder_constructor_t)openssl_ec_public_key_builder);
|
||||
|
||||
|
||||
ENGINE_cleanup();
|
||||
EVP_cleanup();
|
||||
CONF_modules_free();
|
||||
|
||||
|
||||
threading_cleanup();
|
||||
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -198,18 +198,18 @@ static void destroy(private_openssl_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_openssl_plugin_t *this = malloc_thing(private_openssl_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
threading_init();
|
||||
|
||||
|
||||
OPENSSL_config(NULL);
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
|
||||
/* activate support for hardware accelerators */
|
||||
ENGINE_load_builtin_engines();
|
||||
ENGINE_register_all_complete();
|
||||
|
||||
|
||||
/* crypter */
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
|
||||
(crypter_constructor_t)openssl_crypter_create);
|
||||
@@ -231,7 +231,7 @@ plugin_t *plugin_create()
|
||||
(crypter_constructor_t)openssl_crypter_create);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_NULL,
|
||||
(crypter_constructor_t)openssl_crypter_create);
|
||||
|
||||
|
||||
/* hasher */
|
||||
lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
|
||||
(hasher_constructor_t)openssl_hasher_create);
|
||||
@@ -249,7 +249,7 @@ plugin_t *plugin_create()
|
||||
(hasher_constructor_t)openssl_hasher_create);
|
||||
lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
|
||||
(hasher_constructor_t)openssl_hasher_create);
|
||||
|
||||
|
||||
/* ec diffie hellman */
|
||||
lib->crypto->add_dh(lib->crypto, ECP_192_BIT,
|
||||
(dh_constructor_t)openssl_ec_diffie_hellman_create);
|
||||
@@ -261,36 +261,36 @@ plugin_t *plugin_create()
|
||||
(dh_constructor_t)openssl_ec_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, ECP_521_BIT,
|
||||
(dh_constructor_t)openssl_ec_diffie_hellman_create);
|
||||
|
||||
|
||||
/* diffie hellman */
|
||||
lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
|
||||
lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
|
||||
(dh_constructor_t)openssl_diffie_hellman_create);
|
||||
|
||||
|
||||
/* rsa */
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
(builder_constructor_t)openssl_rsa_private_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
(builder_constructor_t)openssl_rsa_public_key_builder);
|
||||
|
||||
|
||||
/* ec */
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_ECDSA,
|
||||
(builder_constructor_t)openssl_ec_private_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ECDSA,
|
||||
(builder_constructor_t)openssl_ec_public_key_builder);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -38,17 +38,17 @@ struct private_openssl_rsa_private_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
openssl_rsa_private_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* RSA object from OpenSSL
|
||||
*/
|
||||
RSA *rsa;
|
||||
|
||||
|
||||
/**
|
||||
* TRUE if the key is from an OpenSSL ENGINE and might not be readable
|
||||
*/
|
||||
bool engine;
|
||||
|
||||
|
||||
/**
|
||||
* reference count
|
||||
*/
|
||||
@@ -82,13 +82,13 @@ static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
|
||||
EVP_PKEY *key;
|
||||
const EVP_MD *hasher;
|
||||
u_int len;
|
||||
|
||||
|
||||
hasher = EVP_get_digestbynid(type);
|
||||
if (!hasher)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
ctx = EVP_MD_CTX_create();
|
||||
key = EVP_PKEY_new();
|
||||
if (!ctx || !key)
|
||||
@@ -111,7 +111,7 @@ static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
|
||||
{
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
|
||||
error:
|
||||
if (key)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ static key_type_t get_type(private_openssl_rsa_private_key_t *this)
|
||||
/**
|
||||
* Implementation of openssl_rsa_private_key.sign.
|
||||
*/
|
||||
static bool sign(private_openssl_rsa_private_key_t *this, signature_scheme_t scheme,
|
||||
static bool sign(private_openssl_rsa_private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature)
|
||||
{
|
||||
switch (scheme)
|
||||
@@ -192,7 +192,7 @@ static public_key_t* get_public_key(private_openssl_rsa_private_key_t *this)
|
||||
chunk_t enc;
|
||||
public_key_t *key;
|
||||
u_char *p;
|
||||
|
||||
|
||||
enc = chunk_alloc(i2d_RSAPublicKey(this->rsa, NULL));
|
||||
p = enc.ptr;
|
||||
i2d_RSAPublicKey(this->rsa, &p);
|
||||
@@ -218,7 +218,7 @@ static bool get_encoding(private_openssl_rsa_private_key_t *this,
|
||||
key_encoding_type_t type, chunk_t *encoding)
|
||||
{
|
||||
u_char *p;
|
||||
|
||||
|
||||
if (this->engine)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -268,7 +268,7 @@ static void destroy(private_openssl_rsa_private_key_t *this)
|
||||
static private_openssl_rsa_private_key_t *create_empty(void)
|
||||
{
|
||||
private_openssl_rsa_private_key_t *this = malloc_thing(private_openssl_rsa_private_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*) (private_key_t*))get_type;
|
||||
this->public.interface.sign = (bool (*) (private_key_t*, signature_scheme_t, chunk_t, chunk_t*))sign;
|
||||
this->public.interface.decrypt = (bool (*) (private_key_t*, chunk_t, chunk_t*))decrypt;
|
||||
@@ -280,10 +280,10 @@ static private_openssl_rsa_private_key_t *create_empty(void)
|
||||
this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (private_key_t* (*) (private_key_t*))get_ref;
|
||||
this->public.interface.destroy = (void (*) (private_key_t*))destroy;
|
||||
|
||||
|
||||
this->engine = FALSE;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -293,9 +293,9 @@ static private_openssl_rsa_private_key_t *create_empty(void)
|
||||
static openssl_rsa_private_key_t *generate(size_t key_size)
|
||||
{
|
||||
private_openssl_rsa_private_key_t *this = create_empty();
|
||||
|
||||
|
||||
this->rsa = RSA_generate_key(key_size, PUBLIC_EXPONENT, NULL, NULL);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ static openssl_rsa_private_key_t *load(chunk_t blob)
|
||||
{
|
||||
u_char *p = blob.ptr;
|
||||
private_openssl_rsa_private_key_t *this = create_empty();
|
||||
|
||||
|
||||
this->rsa = d2i_RSAPrivateKey(NULL, (const u_char**)&p, blob.len);
|
||||
if (!this->rsa)
|
||||
{
|
||||
@@ -330,28 +330,28 @@ static openssl_rsa_private_key_t *load_from_smartcard(char *keyid, char *pin)
|
||||
EVP_PKEY *key;
|
||||
char *engine_id = lib->settings->get_str(lib->settings,
|
||||
"library.plugins.openssl.engine_id", "pkcs11");
|
||||
|
||||
|
||||
ENGINE *engine = ENGINE_by_id(engine_id);
|
||||
if (!engine)
|
||||
{
|
||||
DBG1("engine '%s' is not available", engine_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!ENGINE_init(engine))
|
||||
{
|
||||
DBG1("failed to initialize engine '%s'", engine_id);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!ENGINE_ctrl_cmd_string(engine, "PIN", pin, 0))
|
||||
{
|
||||
DBG1("failed to set PIN on engine '%s'", engine_id);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
key = ENGINE_load_private_key(engine, keyid, NULL, NULL);
|
||||
|
||||
|
||||
if (!key)
|
||||
{
|
||||
DBG1("failed to load private key with ID '%s' from engine '%s'", keyid,
|
||||
@@ -359,13 +359,13 @@ static openssl_rsa_private_key_t *load_from_smartcard(char *keyid, char *pin)
|
||||
goto error;
|
||||
}
|
||||
ENGINE_free(engine);
|
||||
|
||||
|
||||
this = create_empty();
|
||||
this->rsa = EVP_PKEY_get1_RSA(key);
|
||||
this->engine = TRUE;
|
||||
|
||||
|
||||
return &this->public;
|
||||
|
||||
|
||||
error:
|
||||
ENGINE_free(engine);
|
||||
return NULL;
|
||||
@@ -393,7 +393,7 @@ struct private_builder_t {
|
||||
static openssl_rsa_private_key_t *build(private_builder_t *this)
|
||||
{
|
||||
openssl_rsa_private_key_t *key = this->key;
|
||||
|
||||
|
||||
if (this->keyid && this->pin)
|
||||
{
|
||||
key = load_from_smartcard(this->keyid, this->pin);
|
||||
@@ -410,7 +410,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
if (!this->key)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_ASN1_DER:
|
||||
@@ -458,20 +458,20 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *openssl_rsa_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
this->keyid = NULL;
|
||||
this->pin = NULL;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ struct private_openssl_rsa_public_key_t {
|
||||
* Public interface for this signer.
|
||||
*/
|
||||
openssl_rsa_public_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* RSA object from OpenSSL
|
||||
*/
|
||||
RSA *rsa;
|
||||
|
||||
|
||||
/**
|
||||
* reference counter
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ static bool verify_emsa_pkcs1_signature(private_openssl_rsa_public_key_t *this,
|
||||
goto error;
|
||||
}
|
||||
valid = (EVP_VerifyFinal(ctx, signature.ptr, signature.len, key) == 1);
|
||||
|
||||
|
||||
error:
|
||||
if (key)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ static key_type_t get_type(private_openssl_rsa_public_key_t *this)
|
||||
/**
|
||||
* Implementation of public_key_t.verify.
|
||||
*/
|
||||
static bool verify(private_openssl_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
static bool verify(private_openssl_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
@@ -177,7 +177,7 @@ bool openssl_rsa_fingerprint(RSA *rsa, key_encoding_type_t type, chunk_t *fp)
|
||||
hasher_t *hasher;
|
||||
chunk_t key;
|
||||
u_char *p;
|
||||
|
||||
|
||||
if (lib->encoding->get_cache(lib->encoding, type, rsa, fp))
|
||||
{
|
||||
return TRUE;
|
||||
@@ -227,7 +227,7 @@ static bool get_encoding(private_openssl_rsa_public_key_t *this,
|
||||
key_encoding_type_t type, chunk_t *encoding)
|
||||
{
|
||||
u_char *p;
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case KEY_PUB_SPKI_ASN1_DER:
|
||||
@@ -280,7 +280,7 @@ static void destroy(private_openssl_rsa_public_key_t *this)
|
||||
static private_openssl_rsa_public_key_t *create_empty()
|
||||
{
|
||||
private_openssl_rsa_public_key_t *this = malloc_thing(private_openssl_rsa_public_key_t);
|
||||
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(public_key_t *this))get_type;
|
||||
this->public.interface.verify = (bool (*)(public_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t signature))verify;
|
||||
this->public.interface.encrypt = (bool (*)(public_key_t *this, chunk_t crypto, chunk_t *plain))encrypt_;
|
||||
@@ -290,10 +290,10 @@ static private_openssl_rsa_public_key_t *create_empty()
|
||||
this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (public_key_t* (*)(public_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(public_key_t *this))destroy;
|
||||
|
||||
|
||||
this->rsa = NULL;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -304,14 +304,14 @@ static openssl_rsa_public_key_t *load(chunk_t blob)
|
||||
{
|
||||
u_char *p = blob.ptr;
|
||||
private_openssl_rsa_public_key_t *this = create_empty();
|
||||
|
||||
|
||||
this->rsa = d2i_RSAPublicKey(NULL, (const u_char**)&p, blob.len);
|
||||
if (!this->rsa)
|
||||
{
|
||||
destroy(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ struct private_builder_t {
|
||||
static openssl_rsa_public_key_t *build(private_builder_t *this)
|
||||
{
|
||||
openssl_rsa_public_key_t *key = this->key;
|
||||
|
||||
|
||||
free(this);
|
||||
return key;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
if (!this->key)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_ASN1_DER:
|
||||
@@ -373,18 +373,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *openssl_rsa_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,30 +33,30 @@ bool openssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ctx = EVP_MD_CTX_create();
|
||||
|
||||
ctx = EVP_MD_CTX_create();
|
||||
if (!ctx)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!EVP_DigestInit_ex(ctx, hasher, NULL))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!EVP_DigestUpdate(ctx, data.ptr, data.len))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
*hash = chunk_alloc(hasher->md_size);
|
||||
if (!EVP_DigestFinal_ex(ctx, hash->ptr, NULL))
|
||||
{
|
||||
chunk_free(hash);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
ret = TRUE;
|
||||
error:
|
||||
if (ctx)
|
||||
@@ -72,18 +72,18 @@ error:
|
||||
bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
chunk->len = len + (b ? len : 0);
|
||||
chunk->ptr = malloc(chunk->len);
|
||||
memset(chunk->ptr, 0, chunk->len);
|
||||
|
||||
|
||||
/* convert a */
|
||||
offset = len - BN_num_bytes(a);
|
||||
if (!BN_bn2bin(a, chunk->ptr + offset))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/* optionally convert and concatenate b */
|
||||
if (b)
|
||||
{
|
||||
@@ -92,8 +92,8 @@ bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
error:
|
||||
chunk_free(chunk);
|
||||
@@ -107,20 +107,20 @@ error:
|
||||
bool openssl_bn_split(chunk_t chunk, BIGNUM *a, BIGNUM *b)
|
||||
{
|
||||
int len;
|
||||
|
||||
|
||||
if ((chunk.len % 2) != 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
len = chunk.len / 2;
|
||||
|
||||
|
||||
if (!BN_bin2bn(chunk.ptr, len, a) ||
|
||||
!BN_bin2bn(chunk.ptr + len, len, b))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
|
||||
/**
|
||||
* Creates a hash of a given type of a chunk of data.
|
||||
*
|
||||
*
|
||||
* Note: this function allocates memory for the hash
|
||||
*
|
||||
*
|
||||
* @param hash_type NID of the hash
|
||||
* @param data the chunk of data to hash
|
||||
* @param hash chunk that contains the hash
|
||||
@@ -44,9 +44,9 @@ bool openssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash);
|
||||
/**
|
||||
* Concatenates two bignums into a chunk, thereby enfocing the length of
|
||||
* a single BIGNUM, if necessary, by pre-pending it with zeros.
|
||||
*
|
||||
*
|
||||
* Note: this function allocates memory for the chunk
|
||||
*
|
||||
*
|
||||
* @param len the length of a single BIGNUM
|
||||
* @param a first BIGNUM
|
||||
* @param b second BIGNUM
|
||||
@@ -57,7 +57,7 @@ bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk);
|
||||
|
||||
/**
|
||||
* Splits a chunk into two bignums of equal binary length.
|
||||
*
|
||||
*
|
||||
* @param chunk a chunk that contains the two BIGNUMs
|
||||
* @param a first BIGNUM
|
||||
* @param b second BIGNUM
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -70,7 +70,7 @@ struct private_builder_t {
|
||||
static bool present(char* pattern, chunk_t* ch)
|
||||
{
|
||||
u_int len = strlen(pattern);
|
||||
|
||||
|
||||
if (ch->len >= len && strneq(ch->ptr, pattern, len))
|
||||
{
|
||||
*ch = chunk_skip(*ch, len);
|
||||
@@ -85,7 +85,7 @@ static bool present(char* pattern, chunk_t* ch)
|
||||
static bool find_boundary(char* tag, chunk_t *line)
|
||||
{
|
||||
chunk_t name = chunk_empty;
|
||||
|
||||
|
||||
if (!present("-----", line) ||
|
||||
!present(tag, line) ||
|
||||
*line->ptr != ' ')
|
||||
@@ -93,7 +93,7 @@ static bool find_boundary(char* tag, chunk_t *line)
|
||||
return FALSE;
|
||||
}
|
||||
*line = chunk_skip(*line, 1);
|
||||
|
||||
|
||||
/* extract name */
|
||||
name.ptr = line->ptr;
|
||||
while (line->len > 0)
|
||||
@@ -121,7 +121,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
chunk_t decrypted;
|
||||
chunk_t key = {alloca(key_size), key_size};
|
||||
u_int8_t padding, *last_padding_pos, *first_padding_pos;
|
||||
|
||||
|
||||
/* build key from passphrase and IV */
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
|
||||
if (hasher == NULL)
|
||||
@@ -134,7 +134,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
hasher->get_hash(hasher, passphrase, NULL);
|
||||
hasher->get_hash(hasher, salt, hash.ptr);
|
||||
memcpy(key.ptr, hash.ptr, hash.len);
|
||||
|
||||
|
||||
if (key.len > hash.len)
|
||||
{
|
||||
hasher->get_hash(hasher, hash, NULL);
|
||||
@@ -143,7 +143,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
memcpy(key.ptr + hash.len, hash.ptr, key.len - hash.len);
|
||||
}
|
||||
hasher->destroy(hasher);
|
||||
|
||||
|
||||
/* decrypt blob */
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, alg, key_size);
|
||||
if (crypter == NULL)
|
||||
@@ -153,7 +153,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
return NOT_SUPPORTED;
|
||||
}
|
||||
crypter->set_key(crypter, key);
|
||||
|
||||
|
||||
if (iv.len != crypter->get_block_size(crypter) ||
|
||||
blob->len % iv.len)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
crypter->destroy(crypter);
|
||||
memcpy(blob->ptr, decrypted.ptr, blob->len);
|
||||
chunk_free(&decrypted);
|
||||
|
||||
|
||||
/* determine amount of padding */
|
||||
last_padding_pos = blob->ptr + blob->len - 1;
|
||||
padding = *last_padding_pos;
|
||||
@@ -204,7 +204,7 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
|
||||
PEM_POST = 4,
|
||||
PEM_ABORT = 5
|
||||
} state_t;
|
||||
|
||||
|
||||
encryption_algorithm_t alg = ENCR_UNDEFINED;
|
||||
size_t key_size = 0;
|
||||
bool encrypted = FALSE;
|
||||
@@ -216,11 +216,11 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
|
||||
chunk_t passphrase;
|
||||
int try = 0;
|
||||
u_char iv_buf[HASH_SIZE_MD5];
|
||||
|
||||
|
||||
dst.len = 0;
|
||||
iv.ptr = iv_buf;
|
||||
iv.len = 0;
|
||||
|
||||
|
||||
while (fetchline(&src, &line))
|
||||
{
|
||||
if (state == PEM_PRE)
|
||||
@@ -251,14 +251,14 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
|
||||
err_t ugh = NULL;
|
||||
chunk_t name = chunk_empty;
|
||||
chunk_t value = chunk_empty;
|
||||
|
||||
|
||||
/* an empty line separates HEADER and BODY */
|
||||
if (line.len == 0)
|
||||
{
|
||||
state = PEM_BODY;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* we are looking for a parameter: value pair */
|
||||
DBG2(" %.*s", (int)line.len, line.ptr);
|
||||
ugh = extract_parameter_value(&name, &value, &line);
|
||||
@@ -273,7 +273,7 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
|
||||
else if (match("DEK-Info", &name))
|
||||
{
|
||||
chunk_t dek;
|
||||
|
||||
|
||||
if (!extract_token(&dek, ',', &value))
|
||||
{
|
||||
dek = value;
|
||||
@@ -311,13 +311,13 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
|
||||
else /* state is PEM_BODY */
|
||||
{
|
||||
chunk_t data;
|
||||
|
||||
|
||||
/* remove any trailing whitespace */
|
||||
if (!extract_token(&data ,' ', &line))
|
||||
{
|
||||
data = line;
|
||||
}
|
||||
|
||||
|
||||
/* check for PGP armor checksum */
|
||||
if (*data.ptr == '=')
|
||||
{
|
||||
@@ -327,7 +327,7 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
|
||||
DBG2(" armor checksum: %.*s", (int)data.len, data.ptr);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (blob->len - dst.len < data.len / 4 * 3)
|
||||
{
|
||||
state = PEM_ABORT;
|
||||
@@ -383,7 +383,7 @@ static void *build_from_blob(private_builder_t *this, chunk_t blob)
|
||||
{
|
||||
void *cred = NULL;
|
||||
bool pgp = FALSE;
|
||||
|
||||
|
||||
blob = chunk_clone(blob);
|
||||
if (!is_asn1(blob))
|
||||
{
|
||||
@@ -417,21 +417,21 @@ static void *build_from_file(private_builder_t *this, char *file)
|
||||
struct stat sb;
|
||||
void *addr;
|
||||
int fd;
|
||||
|
||||
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
DBG1(" opening '%s' failed: %s", file, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (fstat(fd, &sb) == -1)
|
||||
{
|
||||
DBG1(" getting file size of '%s' failed: %s", file, strerror(errno));
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
{
|
||||
@@ -439,9 +439,9 @@ static void *build_from_file(private_builder_t *this, char *file)
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
cred = build_from_blob(this, chunk_create(addr, sb.st_size));
|
||||
|
||||
|
||||
munmap(addr, sb.st_size);
|
||||
close(fd);
|
||||
return cred;
|
||||
@@ -455,7 +455,7 @@ static void *build_from_fd(private_builder_t *this, int fd)
|
||||
char buf[8096];
|
||||
char *pos = buf;
|
||||
ssize_t len, total = 0;
|
||||
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
len = read(fd, pos, buf + sizeof(buf) - pos);
|
||||
@@ -484,7 +484,7 @@ static void *build_from_fd(private_builder_t *this, int fd)
|
||||
static void *build(private_builder_t *this)
|
||||
{
|
||||
void *cred = NULL;
|
||||
|
||||
|
||||
if (this->pem.ptr)
|
||||
{
|
||||
cred = build_from_blob(this, this->pem);
|
||||
@@ -519,7 +519,7 @@ static chunk_t given_passphrase_cb(chunk_t *passphrase, int try)
|
||||
static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_FROM_FILE:
|
||||
@@ -570,10 +570,10 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
static builder_t *pem_builder(credential_type_t type, int subtype)
|
||||
{
|
||||
private_builder_t *this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
this->type = type;
|
||||
this->subtype = subtype;
|
||||
this->file = NULL;
|
||||
@@ -583,7 +583,7 @@ static builder_t *pem_builder(credential_type_t type, int subtype)
|
||||
this->cb = NULL;
|
||||
this->data = NULL;
|
||||
this->flags = 0;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ static void destroy(private_pem_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_pem_plugin_t *this = malloc_thing(private_pem_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
/* register private key PEM decoding builders */
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_ANY,
|
||||
(builder_constructor_t)private_key_pem_builder);
|
||||
@@ -63,7 +63,7 @@ plugin_t *plugin_create()
|
||||
(builder_constructor_t)private_key_pem_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_DSA,
|
||||
(builder_constructor_t)private_key_pem_builder);
|
||||
|
||||
|
||||
/* register public key PEM decoding builders */
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
|
||||
(builder_constructor_t)public_key_pem_builder);
|
||||
@@ -73,7 +73,7 @@ plugin_t *plugin_create()
|
||||
(builder_constructor_t)public_key_pem_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_DSA,
|
||||
(builder_constructor_t)public_key_pem_builder);
|
||||
|
||||
|
||||
/* register certificate PEM decoding builders */
|
||||
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_ANY,
|
||||
(builder_constructor_t)certificate_pem_builder);
|
||||
@@ -91,7 +91,7 @@ plugin_t *plugin_create()
|
||||
(builder_constructor_t)certificate_pem_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_GPG,
|
||||
(builder_constructor_t)certificate_pem_builder);
|
||||
|
||||
|
||||
/* register pluto specific certificate formats */
|
||||
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_PLUTO_CERT,
|
||||
(builder_constructor_t)certificate_pem_builder);
|
||||
@@ -99,7 +99,7 @@ plugin_t *plugin_create()
|
||||
(builder_constructor_t)certificate_pem_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_PLUTO_CRL,
|
||||
(builder_constructor_t)certificate_pem_builder);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* @defgroup pem_p pem
|
||||
* @ingroup plugins
|
||||
*
|
||||
*
|
||||
* @defgroup pem_plugin pem_plugin
|
||||
* @{ @ingroup pem_p
|
||||
*/
|
||||
|
||||
@@ -90,7 +90,7 @@ ENUM(pgp_sym_alg_names, PGP_SYM_ALG_PLAIN, PGP_SYM_ALG_TWOFISH,
|
||||
static bool read_scalar(chunk_t *blob, size_t bytes, u_int32_t *scalar)
|
||||
{
|
||||
u_int32_t res = 0;
|
||||
|
||||
|
||||
if (bytes > blob->len)
|
||||
{
|
||||
DBG1("PGP data too short to read %d byte scalar", bytes);
|
||||
@@ -112,14 +112,14 @@ static bool old_packet_length(chunk_t *blob, u_int32_t *length)
|
||||
{
|
||||
/* bits 0 and 1 define the packet length type */
|
||||
u_char type;
|
||||
|
||||
|
||||
if (!blob->len)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
type = 0x03 & blob->ptr[0];
|
||||
*blob = chunk_skip(*blob, 1);
|
||||
|
||||
|
||||
if (type > 2)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -133,7 +133,7 @@ static bool old_packet_length(chunk_t *blob, u_int32_t *length)
|
||||
static bool read_mpi(chunk_t *blob, chunk_t *mpi)
|
||||
{
|
||||
u_int32_t bits, bytes;
|
||||
|
||||
|
||||
if (!read_scalar(blob, 2, &bits))
|
||||
{
|
||||
DBG1("PGP data too short to read MPI length");
|
||||
@@ -157,7 +157,7 @@ static public_key_t *parse_public_key(chunk_t blob)
|
||||
{
|
||||
u_int32_t alg;
|
||||
public_key_t *key;
|
||||
|
||||
|
||||
if (!read_scalar(&blob, 1, &alg))
|
||||
{
|
||||
return NULL;
|
||||
@@ -184,7 +184,7 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
|
||||
{
|
||||
chunk_t mpi[2];
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (!read_mpi(&blob, &mpi[i]))
|
||||
@@ -205,7 +205,7 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
|
||||
chunk_t mpi[6];
|
||||
u_int32_t s2k;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (!read_mpi(&blob, &mpi[i]))
|
||||
@@ -227,7 +227,7 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
|
||||
DBG1("%N private key encryption not supported", pgp_sym_alg_names, s2k);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 2; i < 6; i++)
|
||||
{
|
||||
if (!read_mpi(&blob, &mpi[i]))
|
||||
@@ -235,9 +235,9 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* PGP has uses p < q, but we use p > q */
|
||||
return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
BUILD_RSA_MODULUS, mpi[0], BUILD_RSA_PUB_EXP, mpi[1],
|
||||
BUILD_RSA_PRIV_EXP, mpi[2], BUILD_RSA_PRIME2, mpi[3],
|
||||
BUILD_RSA_PRIME1, mpi[4], BUILD_RSA_COEFF, mpi[5],
|
||||
@@ -273,9 +273,9 @@ static private_key_t *parse_private_key(chunk_t blob)
|
||||
u_char tag, type;
|
||||
u_int32_t len, version, created, days, alg;
|
||||
private_key_t *key;
|
||||
|
||||
|
||||
tag = blob.ptr[0];
|
||||
|
||||
|
||||
/* bit 7 must be set */
|
||||
if (!(tag & 0x80))
|
||||
{
|
||||
@@ -288,7 +288,7 @@ static private_key_t *parse_private_key(chunk_t blob)
|
||||
DBG1("new PGP packet format not supported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
type = (tag & 0x3C) >> 2;
|
||||
if (!old_packet_length(&blob, &len) || len > blob.len)
|
||||
{
|
||||
@@ -298,7 +298,7 @@ static private_key_t *parse_private_key(chunk_t blob)
|
||||
packet.len = len;
|
||||
packet.ptr = blob.ptr;
|
||||
blob = chunk_skip(blob, len);
|
||||
|
||||
|
||||
if (!read_scalar(&packet, 1, &version))
|
||||
{
|
||||
return NULL;
|
||||
@@ -377,7 +377,7 @@ struct private_builder_t {
|
||||
static public_key_t *build_public(private_builder_t *this)
|
||||
{
|
||||
public_key_t *key = NULL;
|
||||
|
||||
|
||||
switch (this->type)
|
||||
{
|
||||
case KEY_ANY:
|
||||
@@ -399,7 +399,7 @@ static public_key_t *build_public(private_builder_t *this)
|
||||
static void add_public(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_PGP:
|
||||
@@ -421,19 +421,19 @@ static void add_public(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *pgp_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_ANY && type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->blob = chunk_empty;
|
||||
this->type = type;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_public;
|
||||
this->public.build = (void*(*)(builder_t *this))build_public;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ builder_t *pgp_public_key_builder(key_type_t type)
|
||||
static private_key_t *build_private(private_builder_t *this)
|
||||
{
|
||||
private_key_t *key = NULL;
|
||||
|
||||
|
||||
switch (this->type)
|
||||
{
|
||||
case KEY_ANY:
|
||||
@@ -465,7 +465,7 @@ static private_key_t *build_private(private_builder_t *this)
|
||||
static void add_private(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_PGP:
|
||||
@@ -487,19 +487,19 @@ static void add_private(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *pgp_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_ANY && type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->blob = chunk_empty;
|
||||
this->type = type;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_private;
|
||||
this->public.build = (void*(*)(builder_t *this))build_private;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ static bool build_v3_fingerprint(chunk_t *encoding, va_list args)
|
||||
{
|
||||
hasher_t *hasher;
|
||||
chunk_t n, e;
|
||||
|
||||
|
||||
if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
|
||||
KEY_PART_RSA_PUB_EXP, &e, KEY_PART_END))
|
||||
{
|
||||
|
||||
@@ -41,9 +41,9 @@ static void destroy(private_pgp_plugin_t *this)
|
||||
(builder_constructor_t)pgp_public_key_builder);
|
||||
lib->creds->remove_builder(lib->creds,
|
||||
(builder_constructor_t)pgp_private_key_builder);
|
||||
|
||||
|
||||
lib->encoding->remove_encoder(lib->encoding, pgp_encoder_encode);
|
||||
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ static void destroy(private_pgp_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_pgp_plugin_t *this = malloc_thing(private_pgp_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
|
||||
(builder_constructor_t)pgp_public_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
@@ -64,9 +64,9 @@ plugin_t *plugin_create()
|
||||
(builder_constructor_t)pgp_private_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
(builder_constructor_t)pgp_private_key_builder);
|
||||
|
||||
|
||||
lib->encoding->add_encoder(lib->encoding, pgp_encoder_encode);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ static public_key_t *parse_public_key(chunk_t blob)
|
||||
key_type_t type = KEY_ANY;
|
||||
|
||||
parser = asn1_parser_create(pkinfoObjects, blob);
|
||||
|
||||
|
||||
while (parser->iterate(parser, &objectID, &object))
|
||||
{
|
||||
switch (objectID)
|
||||
@@ -56,7 +56,7 @@ static public_key_t *parse_public_key(chunk_t blob)
|
||||
{
|
||||
int oid = asn1_parse_algorithmIdentifier(object,
|
||||
parser->get_level(parser)+1, NULL);
|
||||
|
||||
|
||||
if (oid == OID_RSA_ENCRYPTION)
|
||||
{
|
||||
type = KEY_RSA;
|
||||
@@ -64,7 +64,7 @@ static public_key_t *parse_public_key(chunk_t blob)
|
||||
else if (oid == OID_EC_PUBLICKEY)
|
||||
{
|
||||
/* we need the whole subjectPublicKeyInfo for EC public keys */
|
||||
key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY,
|
||||
key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY,
|
||||
KEY_ECDSA, BUILD_BLOB_ASN1_DER, blob, BUILD_END);
|
||||
goto end;
|
||||
}
|
||||
@@ -85,11 +85,11 @@ static public_key_t *parse_public_key(chunk_t blob)
|
||||
BUILD_BLOB_ASN1_DER, object, BUILD_END);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
end:
|
||||
parser->destroy(parser);
|
||||
return key;
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,9 +115,9 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
|
||||
chunk_t object;
|
||||
int objectID;
|
||||
bool success = FALSE;
|
||||
|
||||
|
||||
parser = asn1_parser_create(pubkeyObjects, blob);
|
||||
|
||||
|
||||
while (parser->iterate(parser, &objectID, &object))
|
||||
{
|
||||
switch (objectID)
|
||||
@@ -184,10 +184,10 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
|
||||
chunk_t object;
|
||||
int objectID ;
|
||||
bool success = FALSE;
|
||||
|
||||
|
||||
parser = asn1_parser_create(privkeyObjects, blob);
|
||||
parser->set_flags(parser, FALSE, TRUE);
|
||||
|
||||
|
||||
while (parser->iterate(parser, &objectID, &object))
|
||||
{
|
||||
switch (objectID)
|
||||
@@ -233,9 +233,9 @@ end:
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_RSA_PRIV_EXP, d,
|
||||
BUILD_RSA_PRIME1, p, BUILD_RSA_PRIME2, q, BUILD_RSA_EXP1, exp1,
|
||||
BUILD_RSA_PRIME1, p, BUILD_RSA_PRIME2, q, BUILD_RSA_EXP1, exp1,
|
||||
BUILD_RSA_EXP2, exp2, BUILD_RSA_COEFF, coeff, BUILD_END);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ struct private_builder_t {
|
||||
static public_key_t *build_public(private_builder_t *this)
|
||||
{
|
||||
public_key_t *key = NULL;
|
||||
|
||||
|
||||
switch (this->type)
|
||||
{
|
||||
case KEY_ANY:
|
||||
@@ -281,7 +281,7 @@ static public_key_t *build_public(private_builder_t *this)
|
||||
static void add_public(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_ASN1_DER:
|
||||
@@ -303,19 +303,19 @@ static void add_public(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *pkcs1_public_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_ANY && type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->blob = chunk_empty;
|
||||
this->type = type;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_public;
|
||||
this->public.build = (void*(*)(builder_t *this))build_public;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ builder_t *pkcs1_public_key_builder(key_type_t type)
|
||||
static private_key_t *build_private(private_builder_t *this)
|
||||
{
|
||||
private_key_t *key;
|
||||
|
||||
|
||||
key = parse_rsa_private_key(this->blob);
|
||||
free(this);
|
||||
return key;
|
||||
@@ -337,7 +337,7 @@ static private_key_t *build_private(private_builder_t *this)
|
||||
static void add_private(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_ASN1_DER:
|
||||
@@ -359,19 +359,19 @@ static void add_private(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *pkcs1_private_key_builder(key_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != KEY_RSA)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->blob = chunk_empty;
|
||||
this->type = type;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_private;
|
||||
this->public.build = (void*(*)(builder_t *this))build_private;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
bool build_pub(chunk_t *encoding, va_list args)
|
||||
{
|
||||
chunk_t n, e;
|
||||
|
||||
|
||||
if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
|
||||
KEY_PART_RSA_PUB_EXP, &e, KEY_PART_END))
|
||||
{
|
||||
@@ -43,7 +43,7 @@ bool build_pub(chunk_t *encoding, va_list args)
|
||||
bool build_pub_info(chunk_t *encoding, va_list args)
|
||||
{
|
||||
chunk_t n, e;
|
||||
|
||||
|
||||
if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
|
||||
KEY_PART_RSA_PUB_EXP, &e, KEY_PART_END))
|
||||
{
|
||||
@@ -64,7 +64,7 @@ bool build_pub_info(chunk_t *encoding, va_list args)
|
||||
bool build_priv(chunk_t *encoding, va_list args)
|
||||
{
|
||||
chunk_t n, e, d, p, q, exp1, exp2, coeff;
|
||||
|
||||
|
||||
if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
|
||||
KEY_PART_RSA_PUB_EXP, &e, KEY_PART_RSA_PRIV_EXP, &d,
|
||||
KEY_PART_RSA_PRIME1, &p, KEY_PART_RSA_PRIME2, &q,
|
||||
@@ -92,7 +92,7 @@ bool build_priv(chunk_t *encoding, va_list args)
|
||||
static bool hash_pubkey(chunk_t pubkey, chunk_t *hash)
|
||||
{
|
||||
hasher_t *hasher;
|
||||
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||
if (hasher == NULL)
|
||||
{
|
||||
@@ -112,7 +112,7 @@ static bool hash_pubkey(chunk_t pubkey, chunk_t *hash)
|
||||
static bool build_info_sha1(chunk_t *encoding, va_list args)
|
||||
{
|
||||
chunk_t pubkey;
|
||||
|
||||
|
||||
if (build_pub_info(&pubkey, args))
|
||||
{
|
||||
return hash_pubkey(pubkey, encoding);
|
||||
@@ -126,7 +126,7 @@ static bool build_info_sha1(chunk_t *encoding, va_list args)
|
||||
static bool build_sha1(chunk_t *encoding, va_list args)
|
||||
{
|
||||
chunk_t pubkey;
|
||||
|
||||
|
||||
if (build_pub(&pubkey, args))
|
||||
{
|
||||
return hash_pubkey(pubkey, encoding);
|
||||
|
||||
@@ -41,9 +41,9 @@ static void destroy(private_pkcs1_plugin_t *this)
|
||||
(builder_constructor_t)pkcs1_public_key_builder);
|
||||
lib->creds->remove_builder(lib->creds,
|
||||
(builder_constructor_t)pkcs1_private_key_builder);
|
||||
|
||||
|
||||
lib->encoding->remove_encoder(lib->encoding, pkcs1_encoder_encode);
|
||||
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -53,18 +53,18 @@ static void destroy(private_pkcs1_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_pkcs1_plugin_t *this = malloc_thing(private_pkcs1_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
|
||||
(builder_constructor_t)pkcs1_public_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||
(builder_constructor_t)pkcs1_public_key_builder);
|
||||
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
|
||||
(builder_constructor_t)pkcs1_private_key_builder);
|
||||
|
||||
|
||||
lib->encoding->add_encoder(lib->encoding, pkcs1_encoder_encode);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef struct plugin_t plugin_t;
|
||||
* Interface definition of a plugin.
|
||||
*/
|
||||
struct plugin_t {
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a plugin instance.
|
||||
*/
|
||||
|
||||
@@ -37,12 +37,12 @@ struct private_plugin_loader_t {
|
||||
* public functions
|
||||
*/
|
||||
plugin_loader_t public;
|
||||
|
||||
|
||||
/**
|
||||
* list of loaded plugins
|
||||
*/
|
||||
linked_list_t *plugins;
|
||||
|
||||
|
||||
/**
|
||||
* names of loaded plugins
|
||||
*/
|
||||
@@ -59,9 +59,9 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
|
||||
void *handle;
|
||||
plugin_t *plugin;
|
||||
plugin_constructor_t constructor;
|
||||
|
||||
|
||||
snprintf(file, sizeof(file), "%s/libstrongswan-%s.so", path, name);
|
||||
|
||||
|
||||
if (lib->integrity)
|
||||
{
|
||||
if (!lib->integrity->check_file(lib->integrity, name, file))
|
||||
@@ -101,7 +101,7 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
|
||||
return NULL;
|
||||
}
|
||||
DBG2("plugin '%s': loaded successfully", name);
|
||||
|
||||
|
||||
/* we do not store or free dlopen() handles, leak_detective requires
|
||||
* the modules to keep loaded until leak report */
|
||||
return plugin;
|
||||
@@ -115,14 +115,14 @@ static bool load(private_plugin_loader_t *this, char *path, char *list)
|
||||
enumerator_t *enumerator;
|
||||
char *token;
|
||||
bool critical_failed = FALSE;
|
||||
|
||||
|
||||
enumerator = enumerator_create_token(list, " ", " ");
|
||||
while (!critical_failed && enumerator->enumerate(enumerator, &token))
|
||||
{
|
||||
plugin_t *plugin;
|
||||
bool critical = FALSE;
|
||||
int len;
|
||||
|
||||
|
||||
token = strdup(token);
|
||||
len = strlen(token);
|
||||
if (token[len-1] == '!')
|
||||
@@ -158,7 +158,7 @@ static void unload(private_plugin_loader_t *this)
|
||||
{
|
||||
plugin_t *plugin;
|
||||
char *name;
|
||||
|
||||
|
||||
while (this->plugins->remove_first(this->plugins,
|
||||
(void**)&plugin) == SUCCESS)
|
||||
{
|
||||
@@ -176,7 +176,7 @@ static void unload(private_plugin_loader_t *this)
|
||||
static enumerator_t* create_plugin_enumerator(private_plugin_loader_t *this)
|
||||
{
|
||||
return this->names->create_enumerator(this->names);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of plugin_loader_t.destroy
|
||||
@@ -194,15 +194,15 @@ static void destroy(private_plugin_loader_t *this)
|
||||
plugin_loader_t *plugin_loader_create()
|
||||
{
|
||||
private_plugin_loader_t *this = malloc_thing(private_plugin_loader_t);
|
||||
|
||||
|
||||
this->public.load = (bool(*)(plugin_loader_t*, char *path, char *prefix))load;
|
||||
this->public.unload = (void(*)(plugin_loader_t*))unload;
|
||||
this->public.create_plugin_enumerator = (enumerator_t*(*)(plugin_loader_t*))create_plugin_enumerator;
|
||||
this->public.destroy = (void(*)(plugin_loader_t*))destroy;
|
||||
|
||||
|
||||
this->plugins = linked_list_create();
|
||||
this->names = linked_list_create();
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ typedef struct plugin_loader_t plugin_loader_t;
|
||||
/**
|
||||
* The plugin_loader loads plugins from a directory and initializes them
|
||||
*/
|
||||
struct plugin_loader_t {
|
||||
|
||||
struct plugin_loader_t {
|
||||
|
||||
/**
|
||||
* Load a list of plugins from a directory.
|
||||
*
|
||||
@@ -42,19 +42,19 @@ struct plugin_loader_t {
|
||||
* @return TRUE if all critical plugins loaded successfully
|
||||
*/
|
||||
bool (*load)(plugin_loader_t *this, char *path, char *list);
|
||||
|
||||
|
||||
/**
|
||||
* Unload all loaded plugins.
|
||||
*/
|
||||
void (*unload)(plugin_loader_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all loaded plugin names.
|
||||
*
|
||||
* @return enumerator over char*
|
||||
*/
|
||||
enumerator_t* (*create_plugin_enumerator)(plugin_loader_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Unload loaded plugins, destroy plugin_loader instance.
|
||||
*/
|
||||
|
||||
@@ -28,22 +28,22 @@ struct private_pubkey_cert_t {
|
||||
* public functions
|
||||
*/
|
||||
pubkey_cert_t public;
|
||||
|
||||
|
||||
/**
|
||||
* wrapped public key
|
||||
*/
|
||||
public_key_t *key;
|
||||
|
||||
|
||||
/**
|
||||
* dummy issuer id, ID_ANY
|
||||
*/
|
||||
identification_t *issuer;
|
||||
|
||||
|
||||
/**
|
||||
* subject, ID_KEY_ID of the public key
|
||||
*/
|
||||
identification_t *subject;
|
||||
|
||||
|
||||
/**
|
||||
* reference count
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ static id_match_t has_subject(private_pubkey_cert_t *this,
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t fingerprint;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (this->key->get_fingerprint(this->key, type, &fingerprint) &&
|
||||
@@ -112,7 +112,7 @@ static id_match_t has_issuer(private_pubkey_cert_t *this,
|
||||
static bool equals(private_pubkey_cert_t *this, certificate_t *other)
|
||||
{
|
||||
public_key_t *other_key;
|
||||
|
||||
|
||||
other_key = other->get_public_key(other);
|
||||
if (other_key)
|
||||
{
|
||||
@@ -174,7 +174,7 @@ static bool is_newer(certificate_t *this, certificate_t *that)
|
||||
static chunk_t get_encoding(private_pubkey_cert_t *this)
|
||||
{
|
||||
chunk_t encoding;
|
||||
|
||||
|
||||
if (this->key->get_encoding(this->key, KEY_PUB_ASN1_DER, &encoding))
|
||||
{
|
||||
return encoding;
|
||||
@@ -212,7 +212,7 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
|
||||
{
|
||||
private_pubkey_cert_t *this = malloc_thing(private_pubkey_cert_t);
|
||||
chunk_t fingerprint;
|
||||
|
||||
|
||||
this->public.interface.get_type = (certificate_type_t (*)(certificate_t *this))get_type;
|
||||
this->public.interface.get_subject = (identification_t* (*)(certificate_t *this))get_subject;
|
||||
this->public.interface.get_issuer = (identification_t* (*)(certificate_t *this))get_issuer;
|
||||
@@ -226,7 +226,7 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
|
||||
this->public.interface.equals = (bool (*)(certificate_t*, certificate_t *other))equals;
|
||||
this->public.interface.get_ref = (certificate_t* (*)(certificate_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(certificate_t *this))destroy;
|
||||
|
||||
|
||||
this->ref = 1;
|
||||
this->key = key;
|
||||
this->issuer = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||
@@ -238,7 +238,7 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
|
||||
{
|
||||
this->subject = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||
}
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ struct private_builder_t {
|
||||
static pubkey_cert_t *build(private_builder_t *this)
|
||||
{
|
||||
pubkey_cert_t *key = this->key;
|
||||
|
||||
|
||||
free(this);
|
||||
return key;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
{
|
||||
public_key_t *key;
|
||||
va_list args;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case BUILD_BLOB_ASN1_DER:
|
||||
@@ -313,18 +313,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
||||
builder_t *pubkey_cert_builder(certificate_type_t type)
|
||||
{
|
||||
private_builder_t *this;
|
||||
|
||||
|
||||
if (type != CERT_TRUSTED_PUBKEY)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
this = malloc_thing(private_builder_t);
|
||||
|
||||
|
||||
this->key = NULL;
|
||||
this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
|
||||
this->public.build = (void*(*)(builder_t *this))build;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ static void destroy(private_pubkey_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_pubkey_plugin_t *this = malloc_thing(private_pubkey_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_TRUSTED_PUBKEY,
|
||||
|
||||
@@ -47,14 +47,14 @@ static void destroy(private_random_plugin_t *this)
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_random_plugin_t *this = malloc_thing(private_random_plugin_t);
|
||||
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
lib->crypto->add_rng(lib->crypto, RNG_STRONG,
|
||||
|
||||
lib->crypto->add_rng(lib->crypto, RNG_STRONG,
|
||||
(rng_constructor_t)random_rng_create);
|
||||
lib->crypto->add_rng(lib->crypto, RNG_TRUE,
|
||||
lib->crypto->add_rng(lib->crypto, RNG_TRUE,
|
||||
(rng_constructor_t)random_rng_create);
|
||||
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* @defgroup random_p random
|
||||
* @ingroup plugins
|
||||
*
|
||||
*
|
||||
* @defgroup random_plugin random_plugin
|
||||
* @{ @ingroup random_p
|
||||
*/
|
||||
|
||||
@@ -43,12 +43,12 @@ struct private_random_rng_t {
|
||||
* Public random_rng_t interface.
|
||||
*/
|
||||
random_rng_t public;
|
||||
|
||||
|
||||
/**
|
||||
* random device, depends on quality
|
||||
*/
|
||||
int dev;
|
||||
|
||||
|
||||
/**
|
||||
* file we read random bytes from
|
||||
*/
|
||||
@@ -63,9 +63,9 @@ static void get_bytes(private_random_rng_t *this, size_t bytes,
|
||||
{
|
||||
size_t done;
|
||||
ssize_t got;
|
||||
|
||||
|
||||
done = 0;
|
||||
|
||||
|
||||
while (done < bytes)
|
||||
{
|
||||
got = read(this->dev, buffer + done, bytes - done);
|
||||
@@ -120,7 +120,7 @@ random_rng_t *random_rng_create(rng_quality_t quality)
|
||||
{
|
||||
this->file = DEV_URANDOM;
|
||||
}
|
||||
|
||||
|
||||
this->dev = open(this->file, 0);
|
||||
if (this->dev < 0)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup random_rng random_rng
|
||||
* @{ @ingroup random_p
|
||||
@@ -29,7 +29,7 @@ typedef struct random_rng_t random_rng_t;
|
||||
* rng_t implementation on top of /dev/[u]random
|
||||
*/
|
||||
struct random_rng_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements rng_t.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ struct random_rng_t {
|
||||
|
||||
/**
|
||||
* Creates an random_rng_t instance.
|
||||
*
|
||||
*
|
||||
* @param quality required quality of randomness
|
||||
* @return created random_rng_t
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user