removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -44,7 +44,7 @@ const chunk_t ASN1_INTEGER_2 = chunk_from_buf(ASN1_INTEGER_2_str);
|
||||
chunk_t asn1_algorithmIdentifier(int oid)
|
||||
{
|
||||
chunk_t parameters;
|
||||
|
||||
|
||||
/* some algorithmIdentifiers have a NULL parameters field and some do not */
|
||||
switch (oid)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ chunk_t asn1_algorithmIdentifier(int oid)
|
||||
int asn1_known_oid(chunk_t object)
|
||||
{
|
||||
int oid = 0;
|
||||
|
||||
|
||||
while (object.len)
|
||||
{
|
||||
if (oid_names[oid].octet == *object.ptr)
|
||||
@@ -104,17 +104,17 @@ chunk_t asn1_build_known_oid(int n)
|
||||
{
|
||||
chunk_t oid;
|
||||
int i;
|
||||
|
||||
|
||||
if (n < 0 || n >= OID_MAX)
|
||||
{
|
||||
return chunk_empty;
|
||||
}
|
||||
|
||||
|
||||
i = oid_names[n].level + 1;
|
||||
oid = chunk_alloc(2 + i);
|
||||
oid.ptr[0] = ASN1_OID;
|
||||
oid.ptr[1] = i;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
if (oid_names[n].level >= i)
|
||||
@@ -125,7 +125,7 @@ chunk_t asn1_build_known_oid(int n)
|
||||
oid.ptr[--i + 2] = oid_names[n--].octet;
|
||||
}
|
||||
while (i > 0);
|
||||
|
||||
|
||||
return oid;
|
||||
}
|
||||
|
||||
@@ -136,18 +136,18 @@ size_t asn1_length(chunk_t *blob)
|
||||
{
|
||||
u_char n;
|
||||
size_t len;
|
||||
|
||||
|
||||
if (blob->len < 2)
|
||||
{
|
||||
DBG2("insufficient number of octets to parse ASN.1 length");
|
||||
return ASN1_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
|
||||
/* read length field, skip tag and length */
|
||||
n = blob->ptr[1];
|
||||
*blob = chunk_skip(*blob, 2);
|
||||
|
||||
if ((n & 0x80) == 0)
|
||||
|
||||
if ((n & 0x80) == 0)
|
||||
{ /* single length octet */
|
||||
if (n > blob->len)
|
||||
{
|
||||
@@ -156,25 +156,25 @@ size_t asn1_length(chunk_t *blob)
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/* composite length, determine number of length octets */
|
||||
n &= 0x7f;
|
||||
|
||||
|
||||
if (n == 0 || n > blob->len)
|
||||
{
|
||||
DBG2("number of length octets invalid");
|
||||
return ASN1_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
|
||||
if (n > sizeof(len))
|
||||
{
|
||||
DBG2("number of length octets is larger than limit of %d octets",
|
||||
DBG2("number of length octets is larger than limit of %d octets",
|
||||
(int)sizeof(len));
|
||||
return ASN1_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
|
||||
len = 0;
|
||||
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
len = 256*len + *blob->ptr++;
|
||||
@@ -196,7 +196,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *inner)
|
||||
chunk_t res;
|
||||
u_char len;
|
||||
int type;
|
||||
|
||||
|
||||
if (blob->len < 2)
|
||||
{
|
||||
return ASN1_INVALID;
|
||||
@@ -204,7 +204,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *inner)
|
||||
type = blob->ptr[0];
|
||||
len = blob->ptr[1];
|
||||
*blob = chunk_skip(*blob, 2);
|
||||
|
||||
|
||||
if ((len & 0x80) == 0)
|
||||
{ /* single length octet */
|
||||
res.len = len;
|
||||
@@ -250,7 +250,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
|
||||
int tz_hour, tz_min, tz_offset;
|
||||
time_t tm_secs;
|
||||
u_char *eot = NULL;
|
||||
|
||||
|
||||
if ((eot = memchr(utctime->ptr, 'Z', utctime->len)) != NULL)
|
||||
{
|
||||
tz_offset = 0; /* Zulu time with a zero time zone offset */
|
||||
@@ -275,19 +275,19 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
|
||||
{
|
||||
return 0; /* error in time format */
|
||||
}
|
||||
|
||||
|
||||
/* parse ASN.1 time string */
|
||||
{
|
||||
const char* format = (type == ASN1_UTCTIME)? "%2d%2d%2d%2d%2d":
|
||||
"%4d%2d%2d%2d%2d";
|
||||
|
||||
|
||||
if (sscanf(utctime->ptr, format, &tm_year, &tm_mon, &tm_day,
|
||||
&tm_hour, &tm_min) != 5)
|
||||
{
|
||||
return 0; /* error in [yy]yymmddhhmm time format */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* is there a seconds field? */
|
||||
if ((eot - utctime->ptr) == ((type == ASN1_UTCTIME)?12:14))
|
||||
{
|
||||
@@ -300,13 +300,13 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
|
||||
{
|
||||
tm_sec = 0;
|
||||
}
|
||||
|
||||
|
||||
/* representation of two-digit years */
|
||||
if (type == ASN1_UTCTIME)
|
||||
{
|
||||
tm_year += (tm_year < 50) ? 2000 : 1900;
|
||||
}
|
||||
|
||||
|
||||
/* prevent large 32 bit integer overflows */
|
||||
if (sizeof(time_t) == 4 && tm_year > 2038)
|
||||
{
|
||||
@@ -319,7 +319,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
|
||||
return 0; /* error in month format */
|
||||
}
|
||||
tm_mon--;
|
||||
|
||||
|
||||
/* representation of days as 0..30 */
|
||||
tm_day--;
|
||||
|
||||
@@ -352,7 +352,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type)
|
||||
char buf[BUF_LEN];
|
||||
chunk_t formatted_time;
|
||||
struct tm t;
|
||||
|
||||
|
||||
gmtime_r(time, &t);
|
||||
if (type == ASN1_GENERALIZEDTIME)
|
||||
{
|
||||
@@ -364,7 +364,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type)
|
||||
format = "%02d%02d%02d%02d%02d%02dZ";
|
||||
offset = (t.tm_year < 100)? 0 : -100;
|
||||
}
|
||||
snprintf(buf, BUF_LEN, format, t.tm_year + offset,
|
||||
snprintf(buf, BUF_LEN, format, t.tm_year + offset,
|
||||
t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
|
||||
formatted_time.ptr = buf;
|
||||
formatted_time.len = strlen(buf);
|
||||
@@ -377,7 +377,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type)
|
||||
void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
|
||||
{
|
||||
int oid;
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ASN1_OID:
|
||||
@@ -422,30 +422,30 @@ void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
|
||||
bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const char* name)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
|
||||
/* an ASN.1 object must possess at least a tag and length field */
|
||||
if (object->len < 2)
|
||||
{
|
||||
DBG2("L%d - %s: ASN.1 object smaller than 2 octets", level, name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (*object->ptr != type)
|
||||
{
|
||||
DBG2("L%d - %s: ASN1 tag 0x%02x expected, but is 0x%02x",
|
||||
level, name, type, *object->ptr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
len = asn1_length(object);
|
||||
|
||||
|
||||
if (len == ASN1_INVALID_LENGTH || object->len < len)
|
||||
{
|
||||
DBG2("L%d - %s: length of ASN.1 object invalid or too large",
|
||||
level, name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
DBG2("L%d - %s:", level, name);
|
||||
asn1_debug_simple_object(*object, type, FALSE);
|
||||
return TRUE;
|
||||
@@ -473,10 +473,10 @@ int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters
|
||||
chunk_t object;
|
||||
int objectID;
|
||||
int alg = OID_UNKNOWN;
|
||||
|
||||
|
||||
parser = asn1_parser_create(algorithmIdentifierObjects, blob);
|
||||
parser->set_top_level(parser, level0);
|
||||
|
||||
|
||||
while (parser->iterate(parser, &objectID, &object))
|
||||
{
|
||||
switch (objectID)
|
||||
@@ -538,7 +538,7 @@ bool asn1_is_printablestring(chunk_t str)
|
||||
const char printablestring_charset[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 '()+,-./:=?";
|
||||
u_int i;
|
||||
|
||||
|
||||
for (i = 0; i < str.len; i++)
|
||||
{
|
||||
if (strchr(printablestring_charset, str.ptr[i]) == NULL)
|
||||
@@ -588,24 +588,24 @@ u_char* asn1_build_object(chunk_t *object, asn1_t type, size_t datalen)
|
||||
u_char length_buf[4];
|
||||
chunk_t length = { length_buf, 0 };
|
||||
u_char *pos;
|
||||
|
||||
|
||||
/* code the asn.1 length field */
|
||||
asn1_code_length(datalen, &length);
|
||||
|
||||
|
||||
/* allocate memory for the asn.1 TLV object */
|
||||
object->len = 1 + length.len + datalen;
|
||||
object->ptr = malloc(object->len);
|
||||
|
||||
|
||||
/* set position pointer at the start of the object */
|
||||
pos = object->ptr;
|
||||
|
||||
|
||||
/* copy the asn.1 tag field and advance the pointer */
|
||||
*pos++ = type;
|
||||
|
||||
|
||||
/* copy the asn.1 length field and advance the pointer */
|
||||
memcpy(pos, length.ptr, length.len);
|
||||
memcpy(pos, length.ptr, length.len);
|
||||
pos += length.len;
|
||||
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
@@ -615,11 +615,11 @@ u_char* asn1_build_object(chunk_t *object, asn1_t type, size_t datalen)
|
||||
chunk_t asn1_simple_object(asn1_t tag, chunk_t content)
|
||||
{
|
||||
chunk_t object;
|
||||
|
||||
|
||||
u_char *pos = asn1_build_object(&object, tag, content.len);
|
||||
memcpy(pos, content.ptr, content.len);
|
||||
memcpy(pos, content.ptr, content.len);
|
||||
pos += content.len;
|
||||
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -686,8 +686,8 @@ chunk_t asn1_wrap(asn1_t type, const char *mode, ...)
|
||||
u_char *pos;
|
||||
int i;
|
||||
int count = strlen(mode);
|
||||
|
||||
/* sum up lengths of individual chunks */
|
||||
|
||||
/* sum up lengths of individual chunks */
|
||||
va_start(chunks, mode);
|
||||
construct.len = 0;
|
||||
for (i = 0; i < count; i++)
|
||||
@@ -696,16 +696,16 @@ chunk_t asn1_wrap(asn1_t type, const char *mode, ...)
|
||||
construct.len += ch.len;
|
||||
}
|
||||
va_end(chunks);
|
||||
|
||||
|
||||
/* allocate needed memory for construct */
|
||||
pos = asn1_build_object(&construct, type, construct.len);
|
||||
|
||||
|
||||
/* copy or move the chunks */
|
||||
va_start(chunks, mode);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
chunk_t ch = va_arg(chunks, chunk_t);
|
||||
|
||||
|
||||
memcpy(pos, ch.ptr, ch.len);
|
||||
pos += ch.len;
|
||||
|
||||
@@ -722,7 +722,7 @@ chunk_t asn1_wrap(asn1_t type, const char *mode, ...)
|
||||
}
|
||||
}
|
||||
va_end(chunks);
|
||||
|
||||
|
||||
return construct;
|
||||
}
|
||||
|
||||
@@ -748,10 +748,10 @@ time_t asn1_parse_time(chunk_t blob, int level0)
|
||||
chunk_t object;
|
||||
int objectID;
|
||||
time_t utc_time = 0;
|
||||
|
||||
|
||||
parser= asn1_parser_create(timeObjects, blob);
|
||||
parser->set_top_level(parser, level0);
|
||||
|
||||
|
||||
while (parser->iterate(parser, &objectID, &object))
|
||||
{
|
||||
if (objectID == TIME_UTC || objectID == TIME_GENERALIZED)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup asn1i asn1
|
||||
* @{ @ingroup asn1
|
||||
@@ -103,7 +103,7 @@ chunk_t asn1_algorithmIdentifier(int oid);
|
||||
* Converts an ASN.1 OID into a known OID index
|
||||
*
|
||||
* @param object body of an OID
|
||||
* @return index into the oid_names[] table or OID_UNKNOWN
|
||||
* @return index into the oid_names[] table or OID_UNKNOWN
|
||||
*/
|
||||
int asn1_known_oid(chunk_t object);
|
||||
|
||||
@@ -139,7 +139,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *content);
|
||||
* @param blob ASN.1 coded blob
|
||||
* @param level0 top-most level offset
|
||||
* @param params returns optional [ASN.1 coded] parameters
|
||||
* @return known OID index or OID_UNKNOWN
|
||||
* @return known OID index or OID_UNKNOWN
|
||||
*/
|
||||
int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *params);
|
||||
|
||||
@@ -178,7 +178,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type);
|
||||
*
|
||||
* @param time time_t in UTC
|
||||
* @param type ASN1_UTCTIME or ASN1_GENERALIZEDTIME
|
||||
* @return body of an ASN.1 code time object
|
||||
* @return body of an ASN.1 code time object
|
||||
*/
|
||||
chunk_t asn1_from_time(const time_t *time, asn1_t type);
|
||||
|
||||
@@ -187,7 +187,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type);
|
||||
*
|
||||
* @param blob ASN.1 coded time object
|
||||
* @param level0 top-most level offset
|
||||
* @return time_t in UTC
|
||||
* @return time_t in UTC
|
||||
*/
|
||||
time_t asn1_parse_time(chunk_t blob, int level0);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ struct private_asn1_parser_t {
|
||||
bool success;
|
||||
|
||||
/**
|
||||
* Declare object data as private - use debug level 4 to log it
|
||||
* Declare object data as private - use debug level 4 to log it
|
||||
*/
|
||||
bool private;
|
||||
|
||||
@@ -88,7 +88,7 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
u_char *start_ptr;
|
||||
u_int level;
|
||||
asn1Object_t obj;
|
||||
|
||||
|
||||
*object = chunk_empty;
|
||||
|
||||
/* Advance to the next object syntax definition line */
|
||||
@@ -99,7 +99,7 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (obj.flags & ASN1_END) /* end of loop or option found */
|
||||
{
|
||||
if (this->loopAddr[obj.level] && this->blobs[obj.level+1].len > 0)
|
||||
@@ -113,12 +113,12 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
level = this->level0 + obj.level;
|
||||
blob = this->blobs + obj.level;
|
||||
blob1 = blob + 1;
|
||||
start_ptr = blob->ptr;
|
||||
|
||||
|
||||
/* handle ASN.1 defaults values */
|
||||
if ((obj.flags & ASN1_DEF) && (blob->len == 0 || *start_ptr != obj.type) )
|
||||
{
|
||||
@@ -130,9 +130,9 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
/* handle ASN.1 options */
|
||||
|
||||
|
||||
if ((obj.flags & ASN1_OPT)
|
||||
&& (blob->len == 0 || *start_ptr != obj.type))
|
||||
{
|
||||
@@ -145,9 +145,9 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
(this->objects[this->line].level == obj.level)));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
/* an ASN.1 object must possess at least a tag and length field */
|
||||
|
||||
|
||||
if (blob->len < 2)
|
||||
{
|
||||
DBG1("L%d - %s: ASN.1 object smaller than 2 octets",
|
||||
@@ -155,22 +155,22 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
this->success = FALSE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
blob1->len = asn1_length(blob);
|
||||
|
||||
|
||||
if (blob1->len == ASN1_INVALID_LENGTH)
|
||||
{
|
||||
DBG1("L%d - %s: length of ASN.1 object invalid or too large",
|
||||
DBG1("L%d - %s: length of ASN.1 object invalid or too large",
|
||||
level, obj.name);
|
||||
this->success = FALSE;
|
||||
}
|
||||
|
||||
|
||||
blob1->ptr = blob->ptr;
|
||||
blob->ptr += blob1->len;
|
||||
blob->len -= blob1->len;
|
||||
|
||||
|
||||
/* return raw ASN.1 object without prior type checking */
|
||||
|
||||
|
||||
if (obj.flags & ASN1_RAW)
|
||||
{
|
||||
DBG2("L%d - %s:", level, obj.name);
|
||||
@@ -187,10 +187,10 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
|
||||
this->success = FALSE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
DBG2("L%d - %s:", level, obj.name);
|
||||
|
||||
/* In case of "SEQUENCE OF" or "SET OF" start a loop */
|
||||
|
||||
/* In case of "SEQUENCE OF" or "SET OF" start a loop */
|
||||
if (obj.flags & ASN1_LOOP)
|
||||
{
|
||||
if (blob1->len > 0)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup asn1_parser asn1_parser
|
||||
* @{ @ingroup asn1
|
||||
@@ -57,7 +57,7 @@ struct asn1Object_t{
|
||||
typedef struct asn1_parser_t asn1_parser_t;
|
||||
|
||||
/**
|
||||
* Public interface of an ASN.1 parser
|
||||
* Public interface of an ASN.1 parser
|
||||
*/
|
||||
struct asn1_parser_t {
|
||||
|
||||
@@ -106,7 +106,7 @@ struct asn1_parser_t {
|
||||
*/
|
||||
void (*destroy)(asn1_parser_t *this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create an ASN.1 parser
|
||||
*
|
||||
|
||||
+26
-26
@@ -46,14 +46,14 @@ chunk_t chunk_empty = { NULL, 0 };
|
||||
chunk_t chunk_create_clone(u_char *ptr, chunk_t chunk)
|
||||
{
|
||||
chunk_t clone = chunk_empty;
|
||||
|
||||
|
||||
if (chunk.ptr && chunk.len > 0)
|
||||
{
|
||||
clone.ptr = ptr;
|
||||
clone.len = chunk.len;
|
||||
memcpy(clone.ptr, chunk.ptr, chunk.len);
|
||||
}
|
||||
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ size_t chunk_length(const char* mode, ...)
|
||||
{
|
||||
va_list chunks;
|
||||
size_t length = 0;
|
||||
|
||||
|
||||
va_start(chunks, mode);
|
||||
while (TRUE)
|
||||
{
|
||||
@@ -94,13 +94,13 @@ chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...)
|
||||
{
|
||||
va_list chunks;
|
||||
chunk_t construct = chunk_create(ptr, 0);
|
||||
|
||||
|
||||
va_start(chunks, mode);
|
||||
while (TRUE)
|
||||
{
|
||||
bool free_chunk = FALSE, clear_chunk = FALSE;
|
||||
chunk_t ch;
|
||||
|
||||
|
||||
switch (*mode++)
|
||||
{
|
||||
case 's':
|
||||
@@ -111,7 +111,7 @@ chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...)
|
||||
/* FALL */
|
||||
case 'c':
|
||||
ch = va_arg(chunks, chunk_t);
|
||||
memcpy(ptr, ch.ptr, ch.len);
|
||||
memcpy(ptr, ch.ptr, ch.len);
|
||||
ptr += ch.len;
|
||||
construct.len += ch.len;
|
||||
if (clear_chunk)
|
||||
@@ -129,7 +129,7 @@ chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...)
|
||||
break;
|
||||
}
|
||||
va_end(chunks);
|
||||
|
||||
|
||||
return construct;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ void chunk_split(chunk_t chunk, const char *mode, ...)
|
||||
va_list chunks;
|
||||
u_int len;
|
||||
chunk_t *ch;
|
||||
|
||||
|
||||
va_start(chunks, mode);
|
||||
while (TRUE)
|
||||
{
|
||||
@@ -262,19 +262,19 @@ chunk_t chunk_to_hex(chunk_t chunk, char *buf, bool uppercase)
|
||||
{
|
||||
int i, len;
|
||||
char *hexdig = hexdig_lower;
|
||||
|
||||
|
||||
if (uppercase)
|
||||
{
|
||||
hexdig = hexdig_upper;
|
||||
}
|
||||
|
||||
|
||||
len = chunk.len * 2;
|
||||
if (!buf)
|
||||
{
|
||||
buf = malloc(len + 1);
|
||||
}
|
||||
buf[len] = '\0';
|
||||
|
||||
|
||||
for (i = 0; i < chunk.len; i++)
|
||||
{
|
||||
buf[i*2] = hexdig[(chunk.ptr[i] >> 4) & 0xF];
|
||||
@@ -308,7 +308,7 @@ chunk_t chunk_from_hex(chunk_t hex, char *buf)
|
||||
{
|
||||
int i, len;
|
||||
bool odd = FALSE;
|
||||
|
||||
|
||||
len = (hex.len / 2);
|
||||
if (hex.len % 2)
|
||||
{
|
||||
@@ -334,7 +334,7 @@ chunk_t chunk_from_hex(chunk_t hex, char *buf)
|
||||
}
|
||||
|
||||
/** base 64 conversion digits */
|
||||
static char b64digits[] =
|
||||
static char b64digits[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ chunk_t chunk_to_base64(chunk_t chunk, char *buf)
|
||||
{
|
||||
int i, len;
|
||||
char *pos;
|
||||
|
||||
|
||||
len = chunk.len + ((3 - chunk.len % 3) % 3);
|
||||
if (!buf)
|
||||
{
|
||||
@@ -408,7 +408,7 @@ chunk_t chunk_from_base64(chunk_t base64, char *buf)
|
||||
{
|
||||
u_char *pos, byte[4];
|
||||
int i, j, len, outlen;
|
||||
|
||||
|
||||
len = base64.len / 4 * 3;
|
||||
if (!buf)
|
||||
{
|
||||
@@ -456,7 +456,7 @@ int chunk_compare(chunk_t a, chunk_t b)
|
||||
bool chunk_increment(chunk_t chunk)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = chunk.len - 1; i >= 0; i--)
|
||||
{
|
||||
if (++chunk.ptr[i] != 0)
|
||||
@@ -474,7 +474,7 @@ bool chunk_printable(chunk_t chunk, chunk_t *sane, char replace)
|
||||
{
|
||||
bool printable = TRUE;
|
||||
int i;
|
||||
|
||||
|
||||
if (sane)
|
||||
{
|
||||
*sane = chunk_clone(chunk);
|
||||
@@ -495,7 +495,7 @@ bool chunk_printable(chunk_t chunk, chunk_t *sane, char replace)
|
||||
|
||||
/**
|
||||
* Described in header.
|
||||
*
|
||||
*
|
||||
* The implementation is based on Paul Hsieh's SuperFastHash:
|
||||
* http://www.azillionmonkeys.com/qed/hash.html
|
||||
*/
|
||||
@@ -505,15 +505,15 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
|
||||
size_t len = chunk.len;
|
||||
u_int32_t tmp;
|
||||
int rem;
|
||||
|
||||
|
||||
if (!len || data == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
rem = len & 3;
|
||||
len >>= 2;
|
||||
|
||||
|
||||
/* Main loop */
|
||||
for (; len > 0; --len)
|
||||
{
|
||||
@@ -523,7 +523,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
|
||||
data += 2 * sizeof(u_int16_t);
|
||||
hash += hash >> 11;
|
||||
}
|
||||
|
||||
|
||||
/* Handle end cases */
|
||||
switch (rem)
|
||||
{
|
||||
@@ -550,7 +550,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Force "avalanching" of final 127 bits */
|
||||
hash ^= hash << 3;
|
||||
hash += hash >> 5;
|
||||
@@ -558,7 +558,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
|
||||
hash += hash >> 17;
|
||||
hash ^= hash << 25;
|
||||
hash += hash >> 6;
|
||||
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -580,13 +580,13 @@ int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
bool first = TRUE;
|
||||
chunk_t copy = *chunk;
|
||||
int written = 0;
|
||||
|
||||
|
||||
if (!spec->hash)
|
||||
{
|
||||
const void *new_args[] = {&chunk->ptr, &chunk->len};
|
||||
return mem_printf_hook(dst, len, spec, new_args);
|
||||
}
|
||||
|
||||
|
||||
while (copy.len > 0)
|
||||
{
|
||||
if (first)
|
||||
|
||||
@@ -92,7 +92,7 @@ void chunk_split(chunk_t chunk, const char *mode, ...);
|
||||
*
|
||||
* @param chunk contents to write to file
|
||||
* @param path path where file is written to
|
||||
* @param label label specifying file type
|
||||
* @param label label specifying file type
|
||||
* @param mask file mode creation mask
|
||||
* @param force overwrite existing file by force
|
||||
* @return TRUE if write operation was successful
|
||||
@@ -273,7 +273,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash);
|
||||
/**
|
||||
* printf hook function for chunk_t.
|
||||
*
|
||||
* Arguments are:
|
||||
* Arguments are:
|
||||
* chunk_t *chunk
|
||||
* Use #-modifier to print a compact version
|
||||
*/
|
||||
|
||||
@@ -130,14 +130,14 @@ struct builder_t {
|
||||
/**
|
||||
* Add a part to the construct.
|
||||
*
|
||||
* Any added parts are cloned/refcounted by the builder implementation, a
|
||||
* Any added parts are cloned/refcounted by the builder implementation, a
|
||||
* caller may need to free the passed ressources themself.
|
||||
*
|
||||
* @param part kind of part
|
||||
* @param ... part specific variable argument
|
||||
*/
|
||||
void (*add)(builder_t *this, builder_part_t part, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Build the construct with all supplied parts.
|
||||
*
|
||||
|
||||
@@ -41,35 +41,35 @@ struct ac_t {
|
||||
* Implements the certificate_t interface
|
||||
*/
|
||||
certificate_t certificate;
|
||||
|
||||
|
||||
/**
|
||||
* Get the attribute certificate's serial number.
|
||||
*
|
||||
* @return chunk pointing to serialNumber
|
||||
*/
|
||||
chunk_t (*get_serial)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the serial number of the holder certificate.
|
||||
*
|
||||
* @return chunk pointing to serialNumber
|
||||
*/
|
||||
chunk_t (*get_holderSerial)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the issuer of the holder certificate.
|
||||
*
|
||||
* @return holderIssuer as identification_t*
|
||||
*/
|
||||
identification_t* (*get_holderIssuer)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the thauthorityKeyIdentifier.
|
||||
*
|
||||
* @return authKeyIdentifier as chunk_t, to internal data
|
||||
*/
|
||||
chunk_t (*get_authKeyIdentifier)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks if two attribute certificates belong to the same holder
|
||||
*
|
||||
|
||||
@@ -88,7 +88,7 @@ extern enum_name_t *cert_validation_names;
|
||||
/**
|
||||
* An abstract certificate.
|
||||
*
|
||||
* A certificate designs a subject-issuer relationship. It may have an
|
||||
* A certificate designs a subject-issuer relationship. It may have an
|
||||
* associated public key.
|
||||
*/
|
||||
struct certificate_t {
|
||||
@@ -106,7 +106,7 @@ struct certificate_t {
|
||||
* @return subject identity
|
||||
*/
|
||||
identification_t* (*get_subject)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if certificate contains a subject ID.
|
||||
*
|
||||
@@ -117,14 +117,14 @@ struct certificate_t {
|
||||
* @return matching value of best match
|
||||
*/
|
||||
id_match_t (*has_subject)(certificate_t *this, identification_t *subject);
|
||||
|
||||
|
||||
/**
|
||||
* Get the issuer which signed this certificate.
|
||||
*
|
||||
* @return issuer identity
|
||||
*/
|
||||
identification_t* (*get_issuer)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if certificate contains an issuer ID.
|
||||
*
|
||||
@@ -135,7 +135,7 @@ struct certificate_t {
|
||||
* @return matching value of best match
|
||||
*/
|
||||
id_match_t (*has_issuer)(certificate_t *this, identification_t *issuer);
|
||||
|
||||
|
||||
/**
|
||||
* Check if this certificate is issued and signed by a specific issuer.
|
||||
*
|
||||
@@ -143,14 +143,14 @@ struct certificate_t {
|
||||
* @return TRUE if certificate issued by issuer and trusted
|
||||
*/
|
||||
bool (*issued_by)(certificate_t *this, certificate_t *issuer);
|
||||
|
||||
|
||||
/**
|
||||
* Get the public key associated to this certificate.
|
||||
*
|
||||
* @return newly referenced public_key, NULL if none available
|
||||
*/
|
||||
public_key_t* (*get_public_key)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check the lifetime of the certificate.
|
||||
*
|
||||
@@ -161,21 +161,21 @@ struct certificate_t {
|
||||
*/
|
||||
bool (*get_validity)(certificate_t *this, time_t *when,
|
||||
time_t *not_before, time_t *not_after);
|
||||
|
||||
|
||||
/**
|
||||
* Is this newer than that?
|
||||
*
|
||||
* @return TRUE if newer, FALSE otherwise
|
||||
*/
|
||||
bool (*is_newer)(certificate_t *this, certificate_t *that);
|
||||
|
||||
|
||||
/**
|
||||
* Get the certificate in an encoded form.
|
||||
*
|
||||
* @return allocated chunk of encoded cert
|
||||
*/
|
||||
chunk_t (*get_encoding)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if two certificates are equal.
|
||||
*
|
||||
@@ -183,14 +183,14 @@ struct certificate_t {
|
||||
* @return TRUE if certificates are equal
|
||||
*/
|
||||
bool (*equals)(certificate_t *this, certificate_t *other);
|
||||
|
||||
|
||||
/**
|
||||
* Get a new reference to the certificate.
|
||||
*
|
||||
* @return this, with an increased refcount
|
||||
* @return this, with an increased refcount
|
||||
*/
|
||||
certificate_t* (*get_ref)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a certificate.
|
||||
*/
|
||||
|
||||
@@ -56,21 +56,21 @@ struct crl_t {
|
||||
* Implements (parts of) the certificate_t interface
|
||||
*/
|
||||
certificate_t certificate;
|
||||
|
||||
|
||||
/**
|
||||
* Get the CRL serial number.
|
||||
*
|
||||
* @return chunk pointing to internal crlNumber
|
||||
*/
|
||||
chunk_t (*get_serial)(crl_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the the authorityKeyIdentifier.
|
||||
*
|
||||
* @return authKeyIdentifier chunk, point to internal data
|
||||
*/
|
||||
chunk_t (*get_authKeyIdentifier)(crl_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all revoked certificates.
|
||||
*
|
||||
@@ -80,7 +80,7 @@ struct crl_t {
|
||||
* @return enumerator over revoked certificates.
|
||||
*/
|
||||
enumerator_t* (*create_enumerator)(crl_t *this);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /** CRL_H_ @}*/
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct ocsp_response_t ocsp_response_t;
|
||||
typedef enum ocsp_status_t ocsp_status_t;
|
||||
|
||||
/**
|
||||
* OCSP response status
|
||||
* OCSP response status
|
||||
*/
|
||||
enum ocsp_status_t {
|
||||
OCSP_SUCCESSFUL = 0,
|
||||
@@ -53,7 +53,7 @@ struct ocsp_response_t {
|
||||
* Implements certificiate_t interface
|
||||
*/
|
||||
certificate_t certificate;
|
||||
|
||||
|
||||
/**
|
||||
* Check the status of a certificate by this OCSP response.
|
||||
*
|
||||
@@ -65,18 +65,18 @@ struct ocsp_response_t {
|
||||
* @param next_update exptected time of next revocation list
|
||||
* @return certificate revocation status
|
||||
*/
|
||||
cert_validation_t (*get_status)(ocsp_response_t *this,
|
||||
cert_validation_t (*get_status)(ocsp_response_t *this,
|
||||
x509_t *subject, x509_t *issuer,
|
||||
time_t *revocation_time,
|
||||
crl_reason_t *revocation_reason,
|
||||
time_t *this_update, time_t *next_update);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over the contained certificates.
|
||||
*
|
||||
* @return enumerator over certificate_t*
|
||||
*/
|
||||
enumerator_t* (*create_cert_enumerator)(ocsp_response_t *this);
|
||||
enumerator_t* (*create_cert_enumerator)(ocsp_response_t *this);
|
||||
};
|
||||
|
||||
#endif /** OCSP_RESPONSE_H_ @}*/
|
||||
|
||||
@@ -58,42 +58,42 @@ struct x509_t {
|
||||
* Implements certificate_t.
|
||||
*/
|
||||
certificate_t interface;
|
||||
|
||||
|
||||
/**
|
||||
* Get the flags set for this certificate.
|
||||
*
|
||||
* @return set of flags
|
||||
*/
|
||||
x509_flag_t (*get_flags)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the certificate serial number.
|
||||
*
|
||||
* @return chunk pointing to internal serial number
|
||||
*/
|
||||
chunk_t (*get_serial)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the the authorityKeyIdentifier.
|
||||
*
|
||||
* @return authKeyIdentifier as chunk_t, internal data
|
||||
*/
|
||||
chunk_t (*get_authKeyIdentifier)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all subjectAltNames.
|
||||
*
|
||||
* @return enumerator over subjectAltNames as identification_t*
|
||||
*/
|
||||
enumerator_t* (*create_subjectAltName_enumerator)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all CRL URIs.
|
||||
*
|
||||
* @return enumerator over URIs as char*
|
||||
*/
|
||||
enumerator_t* (*create_crl_uri_enumerator)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all OCSP URIs.
|
||||
*
|
||||
|
||||
@@ -41,17 +41,17 @@ struct private_credential_factory_t {
|
||||
* public functions
|
||||
*/
|
||||
credential_factory_t public;
|
||||
|
||||
|
||||
/**
|
||||
* list with entry_t
|
||||
*/
|
||||
linked_list_t *constructors;
|
||||
|
||||
|
||||
/**
|
||||
* Thread specific recursiveness counter
|
||||
*/
|
||||
pthread_key_t recursive;
|
||||
|
||||
|
||||
/**
|
||||
* lock access to builders
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ struct entry_t {
|
||||
static bool builder_filter(entry_t *data, entry_t **in, builder_t **out)
|
||||
{
|
||||
builder_t *builder;
|
||||
|
||||
|
||||
if (data->type == (*in)->type &&
|
||||
data->subtype == (*in)->subtype)
|
||||
{
|
||||
@@ -95,15 +95,15 @@ static enumerator_t* create_builder_enumerator(
|
||||
private_credential_factory_t *this, credential_type_t type, int subtype)
|
||||
{
|
||||
entry_t *data = malloc_thing(entry_t);
|
||||
|
||||
|
||||
data->type = type;
|
||||
data->subtype = subtype;
|
||||
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
return enumerator_create_cleaner(
|
||||
enumerator_create_filter(
|
||||
this->constructors->create_enumerator(this->constructors),
|
||||
(void*)builder_filter, data, free),
|
||||
(void*)builder_filter, data, free),
|
||||
(void*)this->lock->unlock, this->lock);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ static void add_builder(private_credential_factory_t *this,
|
||||
builder_constructor_t constructor)
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->type = type;
|
||||
entry->subtype = subtype;
|
||||
entry->constructor = constructor;
|
||||
@@ -132,7 +132,7 @@ static void remove_builder(private_credential_factory_t *this,
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->constructors->create_enumerator(this->constructors);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -160,10 +160,10 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
||||
void* construct = NULL, *fn, *data;
|
||||
int failures = 0;
|
||||
uintptr_t level;
|
||||
|
||||
|
||||
level = (uintptr_t)pthread_getspecific(this->recursive);
|
||||
pthread_setspecific(this->recursive, (void*)level + 1);
|
||||
|
||||
|
||||
enumerator = create_builder_enumerator(this, type, subtype);
|
||||
while (enumerator->enumerate(enumerator, &builder))
|
||||
{
|
||||
@@ -231,7 +231,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
||||
break;
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
|
||||
construct = builder->build(builder);
|
||||
if (construct)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
||||
if (!construct && !level)
|
||||
{
|
||||
enum_name_t *names = key_type_names;
|
||||
|
||||
|
||||
if (type == CRED_CERTIFICATE)
|
||||
{
|
||||
names = certificate_type_names;
|
||||
@@ -278,11 +278,11 @@ credential_factory_t *credential_factory_create()
|
||||
this->public.add_builder = (void(*)(credential_factory_t*,credential_type_t type, int subtype, builder_constructor_t constructor))add_builder;
|
||||
this->public.remove_builder = (void(*)(credential_factory_t*,builder_constructor_t constructor))remove_builder;
|
||||
this->public.destroy = (void(*)(credential_factory_t*))destroy;
|
||||
|
||||
|
||||
this->constructors = linked_list_create();
|
||||
pthread_key_create(&this->recursive, NULL);
|
||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ extern enum_name_t *credential_type_names;
|
||||
* Manages credential construction functions and creates instances.
|
||||
*/
|
||||
struct credential_factory_t {
|
||||
|
||||
|
||||
/**
|
||||
* Create a credential using a list of builder_part_t's.
|
||||
*
|
||||
@@ -64,12 +64,12 @@ struct credential_factory_t {
|
||||
*/
|
||||
void* (*create)(credential_factory_t *this, credential_type_t type,
|
||||
int subtype, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator for a builder type.
|
||||
*
|
||||
* The build() method has to be called on each enumerated builder to
|
||||
* cleanup associated ressources.
|
||||
* The build() method has to be called on each enumerated builder to
|
||||
* cleanup associated ressources.
|
||||
*
|
||||
* @param type type of credentials the builder creates
|
||||
* @param subtype type specific subtype, such as certificate_type_t
|
||||
@@ -77,7 +77,7 @@ struct credential_factory_t {
|
||||
*/
|
||||
enumerator_t* (*create_builder_enumerator)(credential_factory_t *this,
|
||||
credential_type_t type, int subtype);
|
||||
|
||||
|
||||
/**
|
||||
* Register a builder_t constructor function.
|
||||
*
|
||||
@@ -85,16 +85,16 @@ struct credential_factory_t {
|
||||
* @param constructor builder constructor function to register
|
||||
*/
|
||||
void (*add_builder)(credential_factory_t *this,
|
||||
credential_type_t type, int subtype,
|
||||
credential_type_t type, int subtype,
|
||||
builder_constructor_t constructor);
|
||||
/**
|
||||
* Unregister a builder_t constructor function.
|
||||
*
|
||||
* @param constructor constructor function to unregister.
|
||||
*/
|
||||
void (*remove_builder)(credential_factory_t *this,
|
||||
void (*remove_builder)(credential_factory_t *this,
|
||||
builder_constructor_t constructor);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a credential_factory instance.
|
||||
*/
|
||||
|
||||
@@ -27,22 +27,22 @@ typedef struct private_key_encoding_t private_key_encoding_t;
|
||||
* Private data of an key_encoding_t object.
|
||||
*/
|
||||
struct private_key_encoding_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public key_encoding_t interface.
|
||||
*/
|
||||
key_encoding_t public;
|
||||
|
||||
|
||||
/**
|
||||
* cached encodings, a table for each encoding_type_t, containing chunk_t*
|
||||
*/
|
||||
hashtable_t *cache[KEY_ENCODING_MAX];
|
||||
|
||||
|
||||
/**
|
||||
* Registered encoding fuctions, key_encoder_t
|
||||
*/
|
||||
linked_list_t *encoders;
|
||||
|
||||
|
||||
/**
|
||||
* lock to access cache/encoders
|
||||
*/
|
||||
@@ -56,14 +56,14 @@ bool key_encoding_args(va_list args, ...)
|
||||
{
|
||||
va_list parts, copy;
|
||||
bool failed = FALSE;
|
||||
|
||||
|
||||
va_start(parts, args);
|
||||
|
||||
|
||||
while (!failed)
|
||||
{
|
||||
key_encoding_part_t current, target;
|
||||
chunk_t *out, data;
|
||||
|
||||
|
||||
/* get the part we are looking for */
|
||||
target = va_arg(parts, key_encoding_part_t);
|
||||
if (target == KEY_PART_END)
|
||||
@@ -71,7 +71,7 @@ bool key_encoding_args(va_list args, ...)
|
||||
break;
|
||||
}
|
||||
out = va_arg(parts, chunk_t*);
|
||||
|
||||
|
||||
va_copy(copy, args);
|
||||
while (!failed)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ static bool get_cache(private_key_encoding_t *this, key_encoding_type_t type,
|
||||
void *cache, chunk_t *encoding)
|
||||
{
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
if (type >= KEY_ENCODING_MAX || type < 0)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -143,7 +143,7 @@ static bool encode(private_key_encoding_t *this, key_encoding_type_t type,
|
||||
key_encoder_t encode;
|
||||
bool success = FALSE;
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
if (type >= KEY_ENCODING_MAX || type < 0)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -192,7 +192,7 @@ static void cache(private_key_encoding_t *this, key_encoding_type_t type,
|
||||
void *cache, chunk_t encoding)
|
||||
{
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
if (type >= KEY_ENCODING_MAX || type < 0)
|
||||
{
|
||||
return free(encoding.ptr);
|
||||
@@ -217,7 +217,7 @@ static void clear_cache(private_key_encoding_t *this, void *cache)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
@@ -257,7 +257,7 @@ static void remove_encoder(private_key_encoding_t *this, key_encoder_t encoder)
|
||||
static void destroy(private_key_encoding_t *this)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
/* We explicitly do not free remaining encodings. All keys should
|
||||
@@ -278,7 +278,7 @@ key_encoding_t *key_encoding_create()
|
||||
{
|
||||
private_key_encoding_t *this = malloc_thing(private_key_encoding_t);
|
||||
key_encoding_type_t type;
|
||||
|
||||
|
||||
this->public.encode = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding, ...))encode;
|
||||
this->public.get_cache = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding))get_cache;
|
||||
this->public.cache = (void(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t encoding))cache;
|
||||
@@ -286,14 +286,14 @@ key_encoding_t *key_encoding_create()
|
||||
this->public.add_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))add_encoder;
|
||||
this->public.remove_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))remove_encoder;
|
||||
this->public.destroy = (void(*)(key_encoding_t*))destroy;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
this->cache[type] = hashtable_create(hash, equals, 8);
|
||||
}
|
||||
this->encoders = linked_list_create();
|
||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ enum key_encoding_type_t {
|
||||
KEY_ID_PGPV3,
|
||||
/** PGPv4 fingerprint */
|
||||
KEY_ID_PGPV4,
|
||||
|
||||
|
||||
/** PKCS#1 and similar ASN.1 key encoding */
|
||||
KEY_PUB_ASN1_DER,
|
||||
KEY_PRIV_ASN1_DER,
|
||||
@@ -83,7 +83,7 @@ enum key_encoding_type_t {
|
||||
/** PGP key encoding */
|
||||
KEY_PUB_PGP,
|
||||
KEY_PRIV_PGP,
|
||||
|
||||
|
||||
KEY_ENCODING_MAX,
|
||||
};
|
||||
|
||||
@@ -115,7 +115,7 @@ enum key_encoding_part_t {
|
||||
KEY_PART_ECDSA_PUB_ASN1_DER,
|
||||
/** a DER encoded ECDSA private key */
|
||||
KEY_PART_ECDSA_PRIV_ASN1_DER,
|
||||
|
||||
|
||||
KEY_PART_END,
|
||||
};
|
||||
|
||||
@@ -141,14 +141,14 @@ struct key_encoding_t {
|
||||
*/
|
||||
bool (*encode)(key_encoding_t *this, key_encoding_type_t type, void *cache,
|
||||
chunk_t *encoding, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Clear all cached encodings of a given cache key.
|
||||
*
|
||||
* @param cache key used in encode() for caching
|
||||
*/
|
||||
void (*clear_cache)(key_encoding_t *this, void *cache);
|
||||
|
||||
|
||||
/**
|
||||
* Check for a cached encoding.
|
||||
*
|
||||
@@ -159,7 +159,7 @@ struct key_encoding_t {
|
||||
*/
|
||||
bool (*get_cache)(key_encoding_t *this, key_encoding_type_t type,
|
||||
void *cache, chunk_t *encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Cache a key encoding created externally.
|
||||
*
|
||||
@@ -172,21 +172,21 @@ struct key_encoding_t {
|
||||
*/
|
||||
void (*cache)(key_encoding_t *this, key_encoding_type_t type, void *cache,
|
||||
chunk_t encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Register a key encoder function.
|
||||
*
|
||||
* @param encoder key encoder function to add
|
||||
*/
|
||||
void (*add_encoder)(key_encoding_t *this, key_encoder_t encoder);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a previously registered key encoder function.
|
||||
*
|
||||
* @param encoder key encoder function to remove
|
||||
*/
|
||||
void (*remove_encoder)(key_encoding_t *this, key_encoder_t encoder);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a key_encoding_t.
|
||||
*/
|
||||
|
||||
@@ -22,12 +22,12 @@ bool private_key_equals(private_key_t *this, private_key_t *other)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t a, b;
|
||||
|
||||
|
||||
if (this == other)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (this->get_fingerprint(this, type, &a) &&
|
||||
@@ -46,7 +46,7 @@ bool private_key_belongs_to(private_key_t *private, public_key_t *public)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t a, b;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (private->get_fingerprint(private, type, &a) &&
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup private_key private_key
|
||||
* @{ @ingroup keys
|
||||
@@ -29,14 +29,14 @@ typedef struct private_key_t private_key_t;
|
||||
* Abstract private key interface.
|
||||
*/
|
||||
struct private_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Get the key type.
|
||||
*
|
||||
* @return type of the key
|
||||
*/
|
||||
key_type_t (*get_type)(private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create a signature over a chunk of data.
|
||||
*
|
||||
@@ -45,7 +45,7 @@ struct private_key_t {
|
||||
* @param signature where to allocate created signature
|
||||
* @return TRUE if signature created
|
||||
*/
|
||||
bool (*sign)(private_key_t *this, signature_scheme_t scheme,
|
||||
bool (*sign)(private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature);
|
||||
/**
|
||||
* Decrypt a chunk of data.
|
||||
@@ -55,37 +55,37 @@ struct private_key_t {
|
||||
* @return TRUE if data decrypted and plaintext allocated
|
||||
*/
|
||||
bool (*decrypt)(private_key_t *this, chunk_t crypto, chunk_t *plain);
|
||||
|
||||
|
||||
/**
|
||||
* Get the strength of the key in bytes.
|
||||
*
|
||||
*
|
||||
* @return strength of the key in bytes
|
||||
*/
|
||||
size_t (*get_keysize) (private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the public part from the private key.
|
||||
*
|
||||
* @return public key
|
||||
*/
|
||||
public_key_t* (*get_public_key)(private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if two private keys are equal.
|
||||
*
|
||||
*
|
||||
* @param other other private key
|
||||
* @return TRUE, if equality
|
||||
*/
|
||||
bool (*equals) (private_key_t *this, private_key_t *other);
|
||||
|
||||
|
||||
/**
|
||||
* Check if a private key belongs to a public key.
|
||||
*
|
||||
*
|
||||
* @param public public key
|
||||
* @return TRUE, if keys belong together
|
||||
*/
|
||||
bool (*belongs_to) (private_key_t *this, public_key_t *public);
|
||||
|
||||
|
||||
/**
|
||||
* Get the fingerprint of the key.
|
||||
*
|
||||
@@ -95,7 +95,7 @@ struct private_key_t {
|
||||
*/
|
||||
bool (*get_fingerprint)(private_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *fp);
|
||||
|
||||
|
||||
/**
|
||||
* Get the key in an encoded form as a chunk.
|
||||
*
|
||||
@@ -105,14 +105,14 @@ struct private_key_t {
|
||||
*/
|
||||
bool (*get_encoding)(private_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Increase the refcount to this private key.
|
||||
*
|
||||
* @return this, with an increased refcount
|
||||
*/
|
||||
private_key_t* (*get_ref)(private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Decrease refcount, destroy private_key if no more references.
|
||||
*/
|
||||
|
||||
@@ -49,12 +49,12 @@ bool public_key_equals(public_key_t *this, public_key_t *other)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t a, b;
|
||||
|
||||
|
||||
if (this == other)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (this->get_fingerprint(this, type, &a) &&
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup public_key public_key
|
||||
* @{ @ingroup keys
|
||||
@@ -53,7 +53,7 @@ extern enum_name_t *key_type_names;
|
||||
* Signature scheme for signature creation
|
||||
*
|
||||
* EMSA-PKCS1 signatures are defined in PKCS#1 standard.
|
||||
* A prepended ASN.1 encoded digestInfo field contains the
|
||||
* A prepended ASN.1 encoded digestInfo field contains the
|
||||
* OID of the used hash algorithm.
|
||||
*/
|
||||
enum signature_scheme_t {
|
||||
@@ -107,7 +107,7 @@ struct public_key_t {
|
||||
* @return type of the key
|
||||
*/
|
||||
key_type_t (*get_type)(public_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Verifies a signature against a chunk of data.
|
||||
*
|
||||
@@ -116,9 +116,9 @@ struct public_key_t {
|
||||
* @param signature signature to check
|
||||
* @return TRUE if signature matches
|
||||
*/
|
||||
bool (*verify)(public_key_t *this, signature_scheme_t scheme,
|
||||
bool (*verify)(public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature);
|
||||
|
||||
|
||||
/**
|
||||
* Encrypt a chunk of data.
|
||||
*
|
||||
@@ -127,10 +127,10 @@ struct public_key_t {
|
||||
* @return TRUE if data successfully encrypted
|
||||
*/
|
||||
bool (*encrypt)(public_key_t *this, chunk_t plain, chunk_t *crypto);
|
||||
|
||||
|
||||
/**
|
||||
* Check if two public keys are equal.
|
||||
*
|
||||
*
|
||||
* @param other other public key
|
||||
* @return TRUE, if equality
|
||||
*/
|
||||
@@ -138,11 +138,11 @@ struct public_key_t {
|
||||
|
||||
/**
|
||||
* Get the strength of the key in bytes.
|
||||
*
|
||||
*
|
||||
* @return strength of the key in bytes
|
||||
*/
|
||||
size_t (*get_keysize) (public_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the fingerprint of the key.
|
||||
*
|
||||
@@ -152,7 +152,7 @@ struct public_key_t {
|
||||
*/
|
||||
bool (*get_fingerprint)(public_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *fp);
|
||||
|
||||
|
||||
/**
|
||||
* Get the key in an encoded form as a chunk.
|
||||
*
|
||||
@@ -162,14 +162,14 @@ struct public_key_t {
|
||||
*/
|
||||
bool (*get_encoding)(public_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Increase the refcount of the key.
|
||||
*
|
||||
* @return this with an increased refcount
|
||||
*/
|
||||
public_key_t* (*get_ref)(public_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a public_key instance.
|
||||
*/
|
||||
@@ -187,7 +187,7 @@ bool public_key_equals(public_key_t *this, public_key_t *other);
|
||||
|
||||
/**
|
||||
* Conversion of ASN.1 signature or hash OID to signature scheme.
|
||||
*
|
||||
*
|
||||
* @param oid ASN.1 OID
|
||||
* @return signature_scheme, SIGN_UNKNOWN if OID is unsupported
|
||||
*/
|
||||
|
||||
@@ -34,17 +34,17 @@ struct private_shared_key_t {
|
||||
* public functions
|
||||
*/
|
||||
shared_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* type of this shared key
|
||||
*/
|
||||
shared_key_type_t type;
|
||||
|
||||
|
||||
/**
|
||||
* associated shared key data
|
||||
*/
|
||||
chunk_t key;
|
||||
|
||||
|
||||
/**
|
||||
* reference counter
|
||||
*/
|
||||
@@ -94,16 +94,16 @@ static void destroy(private_shared_key_t *this)
|
||||
shared_key_t *shared_key_create(shared_key_type_t type, chunk_t key)
|
||||
{
|
||||
private_shared_key_t *this = malloc_thing(private_shared_key_t);
|
||||
|
||||
|
||||
this->public.get_type = (shared_key_type_t (*)(shared_key_t *this))get_type;
|
||||
this->public.get_key = (chunk_t (*)(shared_key_t *this))get_key;
|
||||
this->public.get_ref = (shared_key_t* (*)(shared_key_t *this))get_ref;
|
||||
this->public.destroy = (void(*)(shared_key_t*))destroy;
|
||||
|
||||
|
||||
this->type = type;
|
||||
this->key = key;
|
||||
this->ref = 1;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,28 +55,28 @@ extern enum_name_t *shared_key_type_names;
|
||||
* reading.
|
||||
*/
|
||||
struct shared_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Get the kind of this key.
|
||||
*
|
||||
* @return type of the key
|
||||
*/
|
||||
shared_key_type_t (*get_type)(shared_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the shared key data.
|
||||
*
|
||||
* @return chunk pointing to the internal key
|
||||
*/
|
||||
chunk_t (*get_key)(shared_key_t *this);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Increase refcount of the key.
|
||||
*
|
||||
* @return this with an increased refcount
|
||||
* @return this with an increased refcount
|
||||
*/
|
||||
shared_key_t* (*get_ref)(shared_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a shared_key instance if all references are gone.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup crypter crypter
|
||||
* @{ @ingroup crypto
|
||||
@@ -76,7 +76,7 @@ extern enum_name_t *encryption_algorithm_names;
|
||||
* Generic interface for symmetric encryption algorithms.
|
||||
*/
|
||||
struct crypter_t {
|
||||
|
||||
|
||||
/**
|
||||
* Encrypt a chunk of data and allocate space for the encrypted value.
|
||||
*
|
||||
@@ -90,14 +90,14 @@ struct crypter_t {
|
||||
*/
|
||||
void (*encrypt) (crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *encrypted);
|
||||
|
||||
|
||||
/**
|
||||
* Decrypt a chunk of data and allocate space for the decrypted value.
|
||||
*
|
||||
* The length of the iv must equal to get_block_size(), while the length
|
||||
* of data must be a multiple it.
|
||||
* If decrpyted is NULL, the encryption is done in-place (overwriting data).
|
||||
*
|
||||
*
|
||||
* @param data data to decrypt
|
||||
* @param iv initializing vector
|
||||
* @param encrypted chunk to allocate decrypted data, or NULL
|
||||
@@ -107,18 +107,18 @@ struct crypter_t {
|
||||
|
||||
/**
|
||||
* Get the block size of the crypto algorithm.
|
||||
*
|
||||
*
|
||||
* @return block size in bytes
|
||||
*/
|
||||
size_t (*get_block_size) (crypter_t *this);
|
||||
|
||||
/**
|
||||
* Get the key size of the crypto algorithm.
|
||||
*
|
||||
*
|
||||
* @return key size in bytes
|
||||
*/
|
||||
size_t (*get_key_size) (crypter_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Set the key.
|
||||
*
|
||||
@@ -127,7 +127,7 @@ struct crypter_t {
|
||||
* @param key key to set
|
||||
*/
|
||||
void (*set_key) (crypter_t *this, chunk_t key);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a crypter_t object.
|
||||
*/
|
||||
@@ -136,7 +136,7 @@ struct crypter_t {
|
||||
|
||||
/**
|
||||
* Conversion of ASN.1 OID to encryption algorithm.
|
||||
*
|
||||
*
|
||||
* @param oid ASN.1 OID
|
||||
* @param key_size returns size of encryption key in bits
|
||||
* @return encryption algorithm, ENCR_UNDEFINED if OID unsupported
|
||||
@@ -145,7 +145,7 @@ encryption_algorithm_t encryption_algorithm_from_oid(int oid, size_t *key_size);
|
||||
|
||||
/**
|
||||
* Conversion of encryption algorithm to ASN.1 OID.
|
||||
*
|
||||
*
|
||||
* @param alg encryption algorithm
|
||||
* @param key_size size of encryption key in bits
|
||||
* @return ASN.1 OID, OID_UNKNOWN if OID is unknown
|
||||
|
||||
@@ -46,52 +46,52 @@ struct private_crypto_factory_t {
|
||||
* public functions
|
||||
*/
|
||||
crypto_factory_t public;
|
||||
|
||||
|
||||
/**
|
||||
* registered crypters, as entry_t
|
||||
*/
|
||||
linked_list_t *crypters;
|
||||
|
||||
|
||||
/**
|
||||
* registered signers, as entry_t
|
||||
*/
|
||||
linked_list_t *signers;
|
||||
|
||||
|
||||
/**
|
||||
* registered hashers, as entry_t
|
||||
*/
|
||||
linked_list_t *hashers;
|
||||
|
||||
|
||||
/**
|
||||
* registered prfs, as entry_t
|
||||
*/
|
||||
linked_list_t *prfs;
|
||||
|
||||
|
||||
/**
|
||||
* registered rngs, as entry_t
|
||||
*/
|
||||
linked_list_t *rngs;
|
||||
|
||||
|
||||
/**
|
||||
* registered diffie hellman, as entry_t
|
||||
*/
|
||||
linked_list_t *dhs;
|
||||
|
||||
|
||||
/**
|
||||
* test manager to test crypto algorithms
|
||||
*/
|
||||
crypto_tester_t *tester;
|
||||
|
||||
|
||||
/**
|
||||
* whether to test algorithms during registration
|
||||
*/
|
||||
bool test_on_add;
|
||||
|
||||
|
||||
/**
|
||||
* whether to test algorithms on each crypto primitive construction
|
||||
*/
|
||||
bool test_on_create;
|
||||
|
||||
|
||||
/**
|
||||
* rwlock to lock access to modules
|
||||
*/
|
||||
@@ -107,7 +107,7 @@ static crypter_t* create_crypter(private_crypto_factory_t *this,
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
crypter_t *crypter = NULL;
|
||||
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->crypters->create_enumerator(this->crypters);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -141,7 +141,7 @@ static signer_t* create_signer(private_crypto_factory_t *this,
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
signer_t *signer = NULL;
|
||||
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->signers->create_enumerator(this->signers);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -163,7 +163,7 @@ static signer_t* create_signer(private_crypto_factory_t *this,
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->lock->unlock(this->lock);
|
||||
|
||||
|
||||
return signer;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ static rng_t* create_rng(private_crypto_factory_t *this, rng_quality_t quality)
|
||||
entry_t *entry;
|
||||
u_int diff = ~0;
|
||||
rng_constructor_t constr = NULL;
|
||||
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->rngs->create_enumerator(this->rngs);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -311,7 +311,7 @@ static void add_crypter(private_crypto_factory_t *this,
|
||||
this->tester->test_crypter(this->tester, algo, 0, create))
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->algo = algo;
|
||||
entry->create_crypter = create;
|
||||
this->lock->write_lock(this->lock);
|
||||
@@ -328,7 +328,7 @@ static void remove_crypter(private_crypto_factory_t *this,
|
||||
{
|
||||
entry_t *entry;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->crypters->create_enumerator(this->crypters);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -353,7 +353,7 @@ static void add_signer(private_crypto_factory_t *this,
|
||||
this->tester->test_signer(this->tester, algo, create))
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->algo = algo;
|
||||
entry->create_signer = create;
|
||||
this->lock->write_lock(this->lock);
|
||||
@@ -370,7 +370,7 @@ static void remove_signer(private_crypto_factory_t *this,
|
||||
{
|
||||
entry_t *entry;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->signers->create_enumerator(this->signers);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -395,7 +395,7 @@ static void add_hasher(private_crypto_factory_t *this, hash_algorithm_t algo,
|
||||
this->tester->test_hasher(this->tester, algo, create))
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->algo = algo;
|
||||
entry->create_hasher = create;
|
||||
this->lock->write_lock(this->lock);
|
||||
@@ -412,7 +412,7 @@ static void remove_hasher(private_crypto_factory_t *this,
|
||||
{
|
||||
entry_t *entry;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->hashers->create_enumerator(this->hashers);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -437,7 +437,7 @@ static void add_prf(private_crypto_factory_t *this,
|
||||
this->tester->test_prf(this->tester, algo, create))
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->algo = algo;
|
||||
entry->create_prf = create;
|
||||
this->lock->write_lock(this->lock);
|
||||
@@ -453,7 +453,7 @@ static void remove_prf(private_crypto_factory_t *this, prf_constructor_t create)
|
||||
{
|
||||
entry_t *entry;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->prfs->create_enumerator(this->prfs);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -478,7 +478,7 @@ static void add_rng(private_crypto_factory_t *this, rng_quality_t quality,
|
||||
this->tester->test_rng(this->tester, quality, create))
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->algo = quality;
|
||||
entry->create_rng = create;
|
||||
this->lock->write_lock(this->lock);
|
||||
@@ -494,7 +494,7 @@ static void remove_rng(private_crypto_factory_t *this, rng_constructor_t create)
|
||||
{
|
||||
entry_t *entry;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->rngs->create_enumerator(this->rngs);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -516,7 +516,7 @@ static void add_dh(private_crypto_factory_t *this, diffie_hellman_group_t group,
|
||||
dh_constructor_t create)
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->algo = group;
|
||||
entry->create_dh = create;
|
||||
this->lock->write_lock(this->lock);
|
||||
@@ -531,7 +531,7 @@ static void remove_dh(private_crypto_factory_t *this, dh_constructor_t create)
|
||||
{
|
||||
entry_t *entry;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->dhs->create_enumerator(this->dhs);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -713,7 +713,7 @@ static void destroy(private_crypto_factory_t *this)
|
||||
crypto_factory_t *crypto_factory_create()
|
||||
{
|
||||
private_crypto_factory_t *this = malloc_thing(private_crypto_factory_t);
|
||||
|
||||
|
||||
this->public.create_crypter = (crypter_t*(*)(crypto_factory_t*, encryption_algorithm_t, size_t))create_crypter;
|
||||
this->public.create_signer = (signer_t*(*)(crypto_factory_t*, integrity_algorithm_t))create_signer;
|
||||
this->public.create_hasher = (hasher_t*(*)(crypto_factory_t*, hash_algorithm_t))create_hasher;
|
||||
@@ -739,7 +739,7 @@ crypto_factory_t *crypto_factory_create()
|
||||
this->public.create_dh_enumerator = (enumerator_t*(*)(crypto_factory_t*))create_dh_enumerator;
|
||||
this->public.add_test_vector = (void(*)(crypto_factory_t*, transform_type_t type, ...))add_test_vector;
|
||||
this->public.destroy = (void(*)(crypto_factory_t*))destroy;
|
||||
|
||||
|
||||
this->crypters = linked_list_create();
|
||||
this->signers = linked_list_create();
|
||||
this->hashers = linked_list_create();
|
||||
@@ -752,7 +752,7 @@ crypto_factory_t *crypto_factory_create()
|
||||
"libstrongswan.crypto_test.on_add", FALSE);
|
||||
this->test_on_create = lib->settings->get_bool(lib->settings,
|
||||
"libstrongswan.crypto_test.on_create", FALSE);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ struct crypto_factory_t {
|
||||
*/
|
||||
crypter_t* (*create_crypter)(crypto_factory_t *this,
|
||||
encryption_algorithm_t algo, size_t key_size);
|
||||
|
||||
|
||||
/**
|
||||
* Create a symmetric signer instance.
|
||||
*
|
||||
@@ -93,7 +93,7 @@ struct crypto_factory_t {
|
||||
* @return hasher_t instance, NULL if not supported
|
||||
*/
|
||||
hasher_t* (*create_hasher)(crypto_factory_t *this, hash_algorithm_t algo);
|
||||
|
||||
|
||||
/**
|
||||
* Create a pseudo random function instance.
|
||||
*
|
||||
@@ -101,7 +101,7 @@ struct crypto_factory_t {
|
||||
* @return prf_t instance, NULL if not supported
|
||||
*/
|
||||
prf_t* (*create_prf)(crypto_factory_t *this, pseudo_random_function_t algo);
|
||||
|
||||
|
||||
/**
|
||||
* Create a source of randomness.
|
||||
*
|
||||
@@ -109,7 +109,7 @@ struct crypto_factory_t {
|
||||
* @return rng_t instance, NULL if no RNG with such a quality
|
||||
*/
|
||||
rng_t* (*create_rng)(crypto_factory_t *this, rng_quality_t quality);
|
||||
|
||||
|
||||
/**
|
||||
* Create a diffie hellman instance.
|
||||
*
|
||||
@@ -118,7 +118,7 @@ struct crypto_factory_t {
|
||||
*/
|
||||
diffie_hellman_t* (*create_dh)(crypto_factory_t *this,
|
||||
diffie_hellman_group_t group);
|
||||
|
||||
|
||||
/**
|
||||
* Register a crypter constructor.
|
||||
*
|
||||
@@ -128,14 +128,14 @@ struct crypto_factory_t {
|
||||
*/
|
||||
void (*add_crypter)(crypto_factory_t *this, encryption_algorithm_t algo,
|
||||
crypter_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a crypter constructor.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_crypter)(crypto_factory_t *this, crypter_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Register a signer constructor.
|
||||
*
|
||||
@@ -145,14 +145,14 @@ struct crypto_factory_t {
|
||||
*/
|
||||
void (*add_signer)(crypto_factory_t *this, integrity_algorithm_t algo,
|
||||
signer_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a signer constructor.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_signer)(crypto_factory_t *this, signer_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Register a hasher constructor.
|
||||
*
|
||||
@@ -165,14 +165,14 @@ struct crypto_factory_t {
|
||||
*/
|
||||
void (*add_hasher)(crypto_factory_t *this, hash_algorithm_t algo,
|
||||
hasher_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a hasher constructor.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_hasher)(crypto_factory_t *this, hasher_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Register a prf constructor.
|
||||
*
|
||||
@@ -182,14 +182,14 @@ struct crypto_factory_t {
|
||||
*/
|
||||
void (*add_prf)(crypto_factory_t *this, pseudo_random_function_t algo,
|
||||
prf_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a prf constructor.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_prf)(crypto_factory_t *this, prf_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Register a source of randomness.
|
||||
*
|
||||
@@ -197,14 +197,14 @@ struct crypto_factory_t {
|
||||
* @param create constructor function for such a quality
|
||||
*/
|
||||
void (*add_rng)(crypto_factory_t *this, rng_quality_t quality, rng_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a source of randomness.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_rng)(crypto_factory_t *this, rng_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Register a diffie hellman constructor.
|
||||
*
|
||||
@@ -214,49 +214,49 @@ struct crypto_factory_t {
|
||||
*/
|
||||
void (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
|
||||
dh_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a diffie hellman constructor.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_dh)(crypto_factory_t *this, dh_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all registered crypter algorithms.
|
||||
*
|
||||
* @return enumerator over encryption_algorithm_t
|
||||
*/
|
||||
enumerator_t* (*create_crypter_enumerator)(crypto_factory_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all registered signer algorithms.
|
||||
*
|
||||
* @return enumerator over integrity_algorithm_t
|
||||
*/
|
||||
enumerator_t* (*create_signer_enumerator)(crypto_factory_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all registered hasher algorithms.
|
||||
*
|
||||
* @return enumerator over hash_algorithm_t
|
||||
*/
|
||||
enumerator_t* (*create_hasher_enumerator)(crypto_factory_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all registered PRFs.
|
||||
*
|
||||
* @return enumerator over pseudo_random_function_t
|
||||
*/
|
||||
enumerator_t* (*create_prf_enumerator)(crypto_factory_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all registered diffie hellman groups.
|
||||
*
|
||||
* @return enumerator over diffie_hellman_group_t
|
||||
*/
|
||||
enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Add a test vector to the crypto factory.
|
||||
*
|
||||
@@ -264,7 +264,7 @@ struct crypto_factory_t {
|
||||
* @param ... pointer to a test vector, defined in crypto_tester.h
|
||||
*/
|
||||
void (*add_test_vector)(crypto_factory_t *this, transform_type_t type, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a crypto_factory instance.
|
||||
*/
|
||||
|
||||
@@ -24,42 +24,42 @@ typedef struct private_crypto_tester_t private_crypto_tester_t;
|
||||
* Private data of an crypto_tester_t object.
|
||||
*/
|
||||
struct private_crypto_tester_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public crypto_tester_t interface.
|
||||
*/
|
||||
crypto_tester_t public;
|
||||
|
||||
|
||||
/**
|
||||
* List of crypter test vectors
|
||||
*/
|
||||
linked_list_t *crypter;
|
||||
|
||||
|
||||
/**
|
||||
* List of signer test vectors
|
||||
*/
|
||||
linked_list_t *signer;
|
||||
|
||||
|
||||
/**
|
||||
* List of hasher test vectors
|
||||
*/
|
||||
linked_list_t *hasher;
|
||||
|
||||
|
||||
/**
|
||||
* List of PRF test vectors
|
||||
*/
|
||||
linked_list_t *prf;
|
||||
|
||||
|
||||
/**
|
||||
* List of RNG test vectors
|
||||
*/
|
||||
linked_list_t *rng;
|
||||
|
||||
|
||||
/**
|
||||
* Is a test vector required to pass a test?
|
||||
*/
|
||||
bool required;
|
||||
|
||||
|
||||
/**
|
||||
* should we run RNG_TRUE tests? Enough entropy?
|
||||
*/
|
||||
@@ -76,13 +76,13 @@ static bool test_crypter(private_crypto_tester_t *this,
|
||||
crypter_test_vector_t *vector;
|
||||
bool failed = FALSE;
|
||||
u_int tested = 0;
|
||||
|
||||
|
||||
enumerator = this->crypter->create_enumerator(this->crypter);
|
||||
while (enumerator->enumerate(enumerator, &vector))
|
||||
{
|
||||
crypter_t *crypter;
|
||||
chunk_t key, plain, cipher, iv;
|
||||
|
||||
|
||||
if (vector->alg != alg)
|
||||
{
|
||||
continue;
|
||||
@@ -96,14 +96,14 @@ static bool test_crypter(private_crypto_tester_t *this,
|
||||
{ /* key size not supported... */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
failed = FALSE;
|
||||
tested++;
|
||||
|
||||
|
||||
key = chunk_create(vector->key, crypter->get_key_size(crypter));
|
||||
crypter->set_key(crypter, key);
|
||||
iv = chunk_create(vector->iv, crypter->get_block_size(crypter));
|
||||
|
||||
|
||||
/* allocated encryption */
|
||||
plain = chunk_create(vector->plain, vector->len);
|
||||
crypter->encrypt(crypter, plain, iv, &cipher);
|
||||
@@ -132,7 +132,7 @@ static bool test_crypter(private_crypto_tester_t *this,
|
||||
failed = TRUE;
|
||||
}
|
||||
free(plain.ptr);
|
||||
|
||||
|
||||
crypter->destroy(crypter);
|
||||
if (failed)
|
||||
{
|
||||
@@ -167,18 +167,18 @@ static bool test_signer(private_crypto_tester_t *this,
|
||||
signer_test_vector_t *vector;
|
||||
bool failed = FALSE;
|
||||
u_int tested = 0;
|
||||
|
||||
|
||||
enumerator = this->signer->create_enumerator(this->signer);
|
||||
while (enumerator->enumerate(enumerator, &vector))
|
||||
{
|
||||
signer_t *signer;
|
||||
chunk_t key, data, mac;
|
||||
|
||||
|
||||
if (vector->alg != alg)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
tested++;
|
||||
signer = create(alg);
|
||||
if (!signer)
|
||||
@@ -188,12 +188,12 @@ static bool test_signer(private_crypto_tester_t *this,
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
failed = FALSE;
|
||||
|
||||
|
||||
key = chunk_create(vector->key, signer->get_key_size(signer));
|
||||
signer->set_key(signer, key);
|
||||
|
||||
|
||||
/* allocated signature */
|
||||
data = chunk_create(vector->data, vector->len);
|
||||
signer->allocate_signature(signer, data, &mac);
|
||||
@@ -236,7 +236,7 @@ static bool test_signer(private_crypto_tester_t *this,
|
||||
}
|
||||
}
|
||||
free(mac.ptr);
|
||||
|
||||
|
||||
signer->destroy(signer);
|
||||
if (failed)
|
||||
{
|
||||
@@ -271,18 +271,18 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
|
||||
hasher_test_vector_t *vector;
|
||||
bool failed = FALSE;
|
||||
u_int tested = 0;
|
||||
|
||||
|
||||
enumerator = this->hasher->create_enumerator(this->hasher);
|
||||
while (enumerator->enumerate(enumerator, &vector))
|
||||
{
|
||||
hasher_t *hasher;
|
||||
chunk_t data, hash;
|
||||
|
||||
|
||||
if (vector->alg != alg)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
tested++;
|
||||
hasher = create(alg);
|
||||
if (!hasher)
|
||||
@@ -292,9 +292,9 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
failed = FALSE;
|
||||
|
||||
|
||||
/* allocated hash */
|
||||
data = chunk_create(vector->data, vector->len);
|
||||
hasher->allocate_hash(hasher, data, &hash);
|
||||
@@ -326,7 +326,7 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
|
||||
}
|
||||
}
|
||||
free(hash.ptr);
|
||||
|
||||
|
||||
hasher->destroy(hasher);
|
||||
if (failed)
|
||||
{
|
||||
@@ -361,18 +361,18 @@ static bool test_prf(private_crypto_tester_t *this,
|
||||
prf_test_vector_t *vector;
|
||||
bool failed = FALSE;
|
||||
u_int tested = 0;
|
||||
|
||||
|
||||
enumerator = this->prf->create_enumerator(this->prf);
|
||||
while (enumerator->enumerate(enumerator, &vector))
|
||||
{
|
||||
prf_t *prf;
|
||||
chunk_t key, seed, out;
|
||||
|
||||
|
||||
if (vector->alg != alg)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
tested++;
|
||||
prf = create(alg);
|
||||
if (!prf)
|
||||
@@ -382,12 +382,12 @@ static bool test_prf(private_crypto_tester_t *this,
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
failed = FALSE;
|
||||
|
||||
|
||||
key = chunk_create(vector->key, vector->key_size);
|
||||
prf->set_key(prf, key);
|
||||
|
||||
|
||||
/* allocated bytes */
|
||||
seed = chunk_create(vector->seed, vector->len);
|
||||
prf->allocate_bytes(prf, seed, &out);
|
||||
@@ -427,7 +427,7 @@ static bool test_prf(private_crypto_tester_t *this,
|
||||
}
|
||||
}
|
||||
free(out.ptr);
|
||||
|
||||
|
||||
prf->destroy(prf);
|
||||
if (failed)
|
||||
{
|
||||
@@ -462,25 +462,25 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
|
||||
rng_test_vector_t *vector;
|
||||
bool failed = FALSE;
|
||||
u_int tested = 0;
|
||||
|
||||
|
||||
if (!this->rng_true && quality == RNG_TRUE)
|
||||
{
|
||||
DBG1("enabled %N: skipping test (disabled by config)",
|
||||
rng_quality_names, quality);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
enumerator = this->rng->create_enumerator(this->rng);
|
||||
while (enumerator->enumerate(enumerator, &vector))
|
||||
{
|
||||
rng_t *rng;
|
||||
chunk_t data;
|
||||
|
||||
|
||||
if (vector->quality != quality)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
tested++;
|
||||
rng = create(quality);
|
||||
if (!rng)
|
||||
@@ -490,9 +490,9 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
failed = FALSE;
|
||||
|
||||
|
||||
/* allocated bytes */
|
||||
rng->allocate_bytes(rng, vector->len, &data);
|
||||
if (data.len != vector->len)
|
||||
@@ -511,7 +511,7 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
|
||||
failed = TRUE;
|
||||
}
|
||||
free(data.ptr);
|
||||
|
||||
|
||||
rng->destroy(rng);
|
||||
if (failed)
|
||||
{
|
||||
@@ -600,7 +600,7 @@ static void destroy(private_crypto_tester_t *this)
|
||||
crypto_tester_t *crypto_tester_create()
|
||||
{
|
||||
private_crypto_tester_t *this = malloc_thing(private_crypto_tester_t);
|
||||
|
||||
|
||||
this->public.test_crypter = (bool(*)(crypto_tester_t*, encryption_algorithm_t alg,size_t key_size, crypter_constructor_t create))test_crypter;
|
||||
this->public.test_signer = (bool(*)(crypto_tester_t*, integrity_algorithm_t alg, signer_constructor_t create))test_signer;
|
||||
this->public.test_hasher = (bool(*)(crypto_tester_t*, hash_algorithm_t alg, hasher_constructor_t create))test_hasher;
|
||||
@@ -612,18 +612,18 @@ crypto_tester_t *crypto_tester_create()
|
||||
this->public.add_prf_vector = (void(*)(crypto_tester_t*, prf_test_vector_t *vector))add_prf_vector;
|
||||
this->public.add_rng_vector = (void(*)(crypto_tester_t*, rng_test_vector_t *vector))add_rng_vector;
|
||||
this->public.destroy = (void(*)(crypto_tester_t*))destroy;
|
||||
|
||||
|
||||
this->crypter = linked_list_create();
|
||||
this->signer = linked_list_create();
|
||||
this->hasher = linked_list_create();
|
||||
this->prf = linked_list_create();
|
||||
this->rng = linked_list_create();
|
||||
|
||||
|
||||
this->required = lib->settings->get_bool(lib->settings,
|
||||
"libstrongswan.crypto_test.required", FALSE);
|
||||
this->rng_true = lib->settings->get_bool(lib->settings,
|
||||
"libstrongswan.crypto_test.rng_true", FALSE);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,12 +109,12 @@ struct rng_test_vector_t {
|
||||
* Cryptographic primitive testing framework.
|
||||
*/
|
||||
struct crypto_tester_t {
|
||||
|
||||
|
||||
/**
|
||||
* Test a crypter algorithm, optionally using a specified key size.
|
||||
*
|
||||
* @param alg algorithm to test
|
||||
* @param key_size key size to test, 0 for all
|
||||
* @param key_size key size to test, 0 for all
|
||||
* @param create constructor function for the crypter
|
||||
* @return TRUE if test passed
|
||||
*/
|
||||
@@ -183,14 +183,14 @@ struct crypto_tester_t {
|
||||
* @param vector pointer to test vector
|
||||
*/
|
||||
void (*add_prf_vector)(crypto_tester_t *this, prf_test_vector_t *vector);
|
||||
|
||||
|
||||
/**
|
||||
* Add a test vector to test a RNG.
|
||||
*
|
||||
* @param vector pointer to test vector
|
||||
*/
|
||||
void (*add_rng_vector)(crypto_tester_t *this, rng_test_vector_t *vector);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a crypto_tester_t.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup diffie_hellman diffie_hellman
|
||||
* @{ @ingroup crypto
|
||||
@@ -32,7 +32,7 @@ typedef struct diffie_hellman_t diffie_hellman_t;
|
||||
*
|
||||
* The modulus (or group) to use for a Diffie-Hellman calculation.
|
||||
* See IKEv2 RFC 3.3.2 and RFC 3526.
|
||||
*
|
||||
*
|
||||
* ECP groups are defined in RFC 4753 and RFC 5114.
|
||||
*/
|
||||
enum diffie_hellman_group_t {
|
||||
@@ -63,39 +63,39 @@ extern enum_name_t *diffie_hellman_group_names;
|
||||
* Implementation of the Diffie-Hellman algorithm, as in RFC2631.
|
||||
*/
|
||||
struct diffie_hellman_t {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the shared secret of this diffie hellman exchange.
|
||||
*
|
||||
* Space for returned secret is allocated and must be
|
||||
*
|
||||
* Space for returned secret is allocated and must be
|
||||
* freed by the caller.
|
||||
*
|
||||
*
|
||||
* @param secret shared secret will be written into this chunk
|
||||
* @return SUCCESS, FAILED if not both DH values are set
|
||||
*/
|
||||
status_t (*get_shared_secret) (diffie_hellman_t *this, chunk_t *secret);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the public value of partner.
|
||||
*
|
||||
*
|
||||
* Chunk gets cloned and can be destroyed afterwards.
|
||||
*
|
||||
*
|
||||
* @param value public value of partner
|
||||
*/
|
||||
void (*set_other_public_value) (diffie_hellman_t *this, chunk_t value);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the own public value to transmit.
|
||||
*
|
||||
*
|
||||
* Space for returned chunk is allocated and must be freed by the caller.
|
||||
*
|
||||
*
|
||||
* @param value public value of caller is stored at this location
|
||||
*/
|
||||
void (*get_my_public_value) (diffie_hellman_t *this, chunk_t *value);
|
||||
|
||||
|
||||
/**
|
||||
* Get the DH group used.
|
||||
*
|
||||
*
|
||||
* @return DH group set in construction
|
||||
*/
|
||||
diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup hasher hasher
|
||||
* @{ @ingroup crypto
|
||||
@@ -66,43 +66,43 @@ extern enum_name_t *hash_algorithm_names;
|
||||
struct hasher_t {
|
||||
/**
|
||||
* Hash data and write it in the buffer.
|
||||
*
|
||||
*
|
||||
* If the parameter hash is NULL, no result is written back
|
||||
* and more data can be appended to already hashed data.
|
||||
* If not, the result is written back and the hasher is reset.
|
||||
*
|
||||
*
|
||||
* The hash output parameter must hold at least
|
||||
* hash_t.get_block_size() bytes.
|
||||
*
|
||||
*
|
||||
* @param data data to hash
|
||||
* @param hash pointer where the hash will be written
|
||||
*/
|
||||
void (*get_hash) (hasher_t *this, chunk_t data, u_int8_t *hash);
|
||||
|
||||
|
||||
/**
|
||||
* Hash data and allocate space for the hash.
|
||||
*
|
||||
*
|
||||
* If the parameter hash is NULL, no result is written back
|
||||
* and more data can be appended to already hashed data.
|
||||
* If not, the result is written back and the hasher is reset.
|
||||
*
|
||||
*
|
||||
* @param data chunk with data to hash
|
||||
* @param hash chunk which will hold allocated hash
|
||||
*/
|
||||
void (*allocate_hash) (hasher_t *this, chunk_t data, chunk_t *hash);
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the resulting hash.
|
||||
*
|
||||
*
|
||||
* @return hash size in bytes
|
||||
*/
|
||||
size_t (*get_hash_size) (hasher_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Resets the hashers state.
|
||||
*/
|
||||
void (*reset) (hasher_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a hasher object.
|
||||
*/
|
||||
@@ -111,7 +111,7 @@ struct hasher_t {
|
||||
|
||||
/**
|
||||
* Conversion of ASN.1 OID to hash algorithm.
|
||||
*
|
||||
*
|
||||
* @param oid ASN.1 OID
|
||||
* @return hash algorithm, HASH_UNKNOWN if OID unsuported
|
||||
*/
|
||||
@@ -119,7 +119,7 @@ hash_algorithm_t hasher_algorithm_from_oid(int oid);
|
||||
|
||||
/**
|
||||
* Conversion of hash algorithm into ASN.1 OID.
|
||||
*
|
||||
*
|
||||
* @param alg hash algorithm
|
||||
* @return ASN.1 OID, or OID_UNKNOW
|
||||
*/
|
||||
@@ -127,7 +127,7 @@ int hasher_algorithm_to_oid(hash_algorithm_t alg);
|
||||
|
||||
/**
|
||||
* Conversion of hash signature algorithm into ASN.1 OID.
|
||||
*
|
||||
*
|
||||
* @param alg hash algorithm
|
||||
* @return ASN.1 OID if, or OID_UNKNOW
|
||||
*/
|
||||
|
||||
@@ -114,13 +114,13 @@ static char ASN1_pkcs7_encrypted_data_oid_str[] = {
|
||||
0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06
|
||||
};
|
||||
|
||||
static const chunk_t ASN1_pkcs7_data_oid =
|
||||
static const chunk_t ASN1_pkcs7_data_oid =
|
||||
chunk_from_buf(ASN1_pkcs7_data_oid_str);
|
||||
static const chunk_t ASN1_pkcs7_signed_data_oid =
|
||||
chunk_from_buf(ASN1_pkcs7_signed_data_oid_str);
|
||||
static const chunk_t ASN1_pkcs7_enveloped_data_oid =
|
||||
chunk_from_buf(ASN1_pkcs7_enveloped_data_oid_str);
|
||||
static const chunk_t ASN1_pkcs7_signed_enveloped_data_oid =
|
||||
static const chunk_t ASN1_pkcs7_signed_enveloped_data_oid =
|
||||
chunk_from_buf(ASN1_pkcs7_signed_enveloped_data_oid_str);
|
||||
static const chunk_t ASN1_pkcs7_digested_data_oid =
|
||||
chunk_from_buf(ASN1_pkcs7_digested_data_oid_str);
|
||||
@@ -140,7 +140,7 @@ static u_char ASN1_des_cbc_oid_str[] = {
|
||||
0x2B, 0x0E, 0x03, 0x02, 0x07
|
||||
};
|
||||
|
||||
static const chunk_t ASN1_3des_ede_cbc_oid =
|
||||
static const chunk_t ASN1_3des_ede_cbc_oid =
|
||||
chunk_from_buf(ASN1_3des_ede_cbc_oid_str);
|
||||
static const chunk_t ASN1_des_cbc_oid =
|
||||
chunk_from_buf(ASN1_des_cbc_oid_str);
|
||||
@@ -769,7 +769,7 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
|
||||
*/
|
||||
{
|
||||
rng_t *rng;
|
||||
|
||||
|
||||
rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE);
|
||||
rng->allocate_bytes(rng, crypter->get_key_size(crypter), &symmetricKey);
|
||||
DBG4(" symmetric encryption key: %B", &symmetricKey);
|
||||
@@ -808,12 +808,12 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
|
||||
chunk_clear(&in);
|
||||
DBG3(" encrypted data: %B", &out);
|
||||
|
||||
/* build pkcs7 enveloped data object */
|
||||
/* build pkcs7 enveloped data object */
|
||||
{
|
||||
chunk_t contentEncryptionAlgorithm = asn1_wrap(ASN1_SEQUENCE, "cm",
|
||||
alg_oid,
|
||||
asn1_wrap(ASN1_OCTET_STRING, "m", iv));
|
||||
|
||||
|
||||
chunk_t encryptedContentInfo = asn1_wrap(ASN1_SEQUENCE, "cmm",
|
||||
ASN1_pkcs7_data_oid,
|
||||
contentEncryptionAlgorithm,
|
||||
@@ -866,7 +866,7 @@ bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
|
||||
if(this->data.ptr != NULL)
|
||||
{
|
||||
hasher_t *hasher;
|
||||
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, alg);
|
||||
if (hasher == NULL)
|
||||
{
|
||||
@@ -874,13 +874,13 @@ bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
|
||||
hash_algorithm_names, alg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* take the current time as signingTime */
|
||||
time_t now = time(NULL);
|
||||
chunk_t signingTime = asn1_from_time(&now, ASN1_UTCTIME);
|
||||
|
||||
chunk_t messageDigest, attributes;
|
||||
|
||||
|
||||
hasher->allocate_hash(hasher, this->data, &messageDigest);
|
||||
hasher->destroy(hasher);
|
||||
this->attributes->set_attribute(this->attributes,
|
||||
@@ -1008,7 +1008,7 @@ end:
|
||||
static private_pkcs7_t *pkcs7_create_empty(void)
|
||||
{
|
||||
private_pkcs7_t *this = malloc_thing(private_pkcs7_t);
|
||||
|
||||
|
||||
/* initialize */
|
||||
this->type = OID_UNKNOWN;
|
||||
this->content = chunk_empty;
|
||||
@@ -1043,7 +1043,7 @@ static private_pkcs7_t *pkcs7_create_empty(void)
|
||||
pkcs7_t *pkcs7_create_from_chunk(chunk_t chunk, u_int level)
|
||||
{
|
||||
private_pkcs7_t *this = pkcs7_create_empty();
|
||||
|
||||
|
||||
this->level = level + 2;
|
||||
if (!parse_contentInfo(chunk, level, this))
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup pkcs7 pkcs7
|
||||
* @{ @ingroup crypto
|
||||
@@ -38,35 +38,35 @@ typedef struct pkcs7_t pkcs7_t;
|
||||
struct pkcs7_t {
|
||||
/**
|
||||
* Check if the PKCS#7 contentType is data
|
||||
*
|
||||
*
|
||||
* @return TRUE if the contentType is data
|
||||
*/
|
||||
bool (*is_data) (pkcs7_t *this);
|
||||
|
||||
/**
|
||||
* Check if the PKCS#7 contentType is signedData
|
||||
*
|
||||
*
|
||||
* @return TRUE if the contentType is signedData
|
||||
*/
|
||||
bool (*is_signedData) (pkcs7_t *this);
|
||||
|
||||
/**
|
||||
* Check if the PKCS#7 contentType is envelopedData
|
||||
*
|
||||
*
|
||||
* @return TRUE if the contentType is envelopedData
|
||||
*/
|
||||
bool (*is_envelopedData) (pkcs7_t *this);
|
||||
|
||||
/**
|
||||
* Parse a PKCS#7 data content.
|
||||
*
|
||||
*
|
||||
* @return TRUE if parsing was successful
|
||||
*/
|
||||
bool (*parse_data) (pkcs7_t *this);
|
||||
|
||||
/**
|
||||
* Parse a PKCS#7 signedData content.
|
||||
*
|
||||
*
|
||||
* @param cacert cacert used to verify the signature
|
||||
* @return TRUE if parsing was successful
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ struct pkcs7_t {
|
||||
|
||||
/**
|
||||
* Parse a PKCS#7 envelopedData content.
|
||||
*
|
||||
*
|
||||
* @param serialNumber serialNumber of the request
|
||||
* @param key private key used to decrypt the symmetric key
|
||||
* @return TRUE if parsing was successful
|
||||
@@ -97,21 +97,21 @@ struct pkcs7_t {
|
||||
|
||||
/**
|
||||
* Create an iterator for the certificates.
|
||||
*
|
||||
*
|
||||
* @return iterator for the certificates
|
||||
*/
|
||||
iterator_t *(*create_certificate_iterator) (pkcs7_t *this);
|
||||
|
||||
/**
|
||||
* Add a certificate.
|
||||
*
|
||||
*
|
||||
* @param cert certificate to be included
|
||||
*/
|
||||
void (*set_certificate) (pkcs7_t *this, x509_t *cert);
|
||||
|
||||
/**
|
||||
* Add authenticated attributes.
|
||||
*
|
||||
*
|
||||
* @param attributes attributes to be included
|
||||
*/
|
||||
void (*set_attributes) (pkcs7_t *this, pkcs9_t *attributes);
|
||||
@@ -151,7 +151,7 @@ struct pkcs7_t {
|
||||
|
||||
/**
|
||||
* Read a PKCS#7 contentInfo object from a DER encoded chunk.
|
||||
*
|
||||
*
|
||||
* @param chunk chunk containing DER encoded data
|
||||
* @param level ASN.1 parsing start level
|
||||
* @return created pkcs7_contentInfo object, or NULL if invalid.
|
||||
@@ -160,7 +160,7 @@ pkcs7_t *pkcs7_create_from_chunk(chunk_t chunk, u_int level);
|
||||
|
||||
/**
|
||||
* Create a PKCS#7 contentInfo object
|
||||
*
|
||||
*
|
||||
* @param data chunk containing data
|
||||
* @return created pkcs7_contentInfo object.
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ struct attribute_t {
|
||||
|
||||
/**
|
||||
* Destroys the attribute.
|
||||
*
|
||||
*
|
||||
* @param this attribute to destroy
|
||||
*/
|
||||
void (*destroy) (attribute_t *this);
|
||||
@@ -243,7 +243,7 @@ static void build_encoding(private_pkcs9_t *this)
|
||||
/* allocate memory for the attributes and build the encoding */
|
||||
{
|
||||
u_char *pos = asn1_build_object(&this->encoding, ASN1_SET, attributes_len);
|
||||
|
||||
|
||||
iterator = this->attributes->create_iterator(this->attributes, TRUE);
|
||||
|
||||
while (iterator->iterate(iterator, (void**)&attribute))
|
||||
@@ -346,7 +346,7 @@ static void destroy(private_pkcs9_t *this)
|
||||
static private_pkcs9_t *pkcs9_create_empty(void)
|
||||
{
|
||||
private_pkcs9_t *this = malloc_thing(private_pkcs9_t);
|
||||
|
||||
|
||||
/* initialize */
|
||||
this->encoding = chunk_empty;
|
||||
this->attributes = linked_list_create();
|
||||
@@ -452,7 +452,7 @@ end:
|
||||
pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level)
|
||||
{
|
||||
private_pkcs9_t *this = pkcs9_create_empty();
|
||||
|
||||
|
||||
this->encoding = chunk_clone(chunk);
|
||||
|
||||
if (!parse_attributes(chunk, level, this))
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup pkcs9 pkcs9
|
||||
* @{ @ingroup crypto
|
||||
@@ -29,7 +29,7 @@ typedef struct pkcs9_t pkcs9_t;
|
||||
* PKCS#9 attributes.
|
||||
*/
|
||||
struct pkcs9_t {
|
||||
|
||||
|
||||
/**
|
||||
* Generate ASN.1 encoding of attribute list
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ struct pkcs9_t {
|
||||
* Adds a PKCS#9 attribute
|
||||
*
|
||||
* @param oid OID of the attribute
|
||||
* @param value ASN.1 encoded value of the attribute
|
||||
* @param value ASN.1 encoded value of the attribute
|
||||
*/
|
||||
void (*set_attribute) (pkcs9_t *this, int oid, chunk_t value);
|
||||
|
||||
@@ -68,7 +68,7 @@ struct pkcs9_t {
|
||||
/**
|
||||
* Add a PKCS#9 messageDigest attribute
|
||||
*
|
||||
* @param value messageDigest
|
||||
* @param value messageDigest
|
||||
*/
|
||||
void (*set_messageDigest) (pkcs9_t *this, chunk_t value);
|
||||
|
||||
@@ -80,7 +80,7 @@ struct pkcs9_t {
|
||||
|
||||
/**
|
||||
* Read a PKCS#9 attribute list from a DER encoded chunk.
|
||||
*
|
||||
*
|
||||
* @param chunk chunk containing DER encoded data
|
||||
* @param level ASN.1 parsing start level
|
||||
* @return created pkcs9 attribute list, or NULL if invalid.
|
||||
@@ -89,7 +89,7 @@ pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level);
|
||||
|
||||
/**
|
||||
* Create an empty PKCS#9 attribute list
|
||||
*
|
||||
*
|
||||
* @return created pkcs9 attribute list.
|
||||
*/
|
||||
pkcs9_t *pkcs9_create(void);
|
||||
|
||||
@@ -22,34 +22,34 @@ typedef struct private_prf_plus_t private_prf_plus_t;
|
||||
|
||||
/**
|
||||
* Private data of an prf_plus_t object.
|
||||
*
|
||||
*
|
||||
*/
|
||||
struct private_prf_plus_t {
|
||||
/**
|
||||
* Public interface of prf_plus_t.
|
||||
*/
|
||||
prf_plus_t public;
|
||||
|
||||
|
||||
/**
|
||||
* PRF to use.
|
||||
*/
|
||||
prf_t *prf;
|
||||
|
||||
|
||||
/**
|
||||
* Initial seed.
|
||||
*/
|
||||
chunk_t seed;
|
||||
|
||||
|
||||
/**
|
||||
* Buffer to store current PRF result.
|
||||
*/
|
||||
chunk_t buffer;
|
||||
|
||||
|
||||
/**
|
||||
* Already given out bytes in current buffer.
|
||||
*/
|
||||
size_t given_out;
|
||||
|
||||
|
||||
/**
|
||||
* Octet which will be appended to the seed.
|
||||
*/
|
||||
@@ -60,18 +60,18 @@ struct private_prf_plus_t {
|
||||
* Implementation of prf_plus_t.get_bytes.
|
||||
*/
|
||||
static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
|
||||
{
|
||||
{
|
||||
chunk_t appending_chunk;
|
||||
size_t bytes_in_round;
|
||||
size_t total_bytes_written = 0;
|
||||
|
||||
|
||||
appending_chunk.ptr = &(this->appending_octet);
|
||||
appending_chunk.len = 1;
|
||||
|
||||
|
||||
while (length > 0)
|
||||
{ /* still more to do... */
|
||||
if (this->buffer.len == this->given_out)
|
||||
{ /* no bytes left in buffer, get next*/
|
||||
{ /* no bytes left in buffer, get next*/
|
||||
this->prf->get_bytes(this->prf, this->buffer, NULL);
|
||||
this->prf->get_bytes(this->prf, this->seed, NULL);
|
||||
this->prf->get_bytes(this->prf, appending_chunk, this->buffer.ptr);
|
||||
@@ -82,7 +82,7 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
|
||||
bytes_in_round = min(length, this->buffer.len - this->given_out);
|
||||
/* copy bytes from buffer with offset */
|
||||
memcpy(buffer + total_bytes_written, this->buffer.ptr + this->given_out, bytes_in_round);
|
||||
|
||||
|
||||
length -= bytes_in_round;
|
||||
this->given_out += bytes_in_round;
|
||||
total_bytes_written += bytes_in_round;
|
||||
@@ -91,7 +91,7 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
|
||||
|
||||
/**
|
||||
* Implementation of prf_plus_t.allocate_bytes.
|
||||
*/
|
||||
*/
|
||||
static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chunk)
|
||||
{
|
||||
if (length)
|
||||
@@ -123,23 +123,23 @@ prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
|
||||
{
|
||||
private_prf_plus_t *this;
|
||||
chunk_t appending_chunk;
|
||||
|
||||
|
||||
this = malloc_thing(private_prf_plus_t);
|
||||
|
||||
/* set public methods */
|
||||
this->public.get_bytes = (void (*)(prf_plus_t *,size_t,u_int8_t*))get_bytes;
|
||||
this->public.allocate_bytes = (void (*)(prf_plus_t *,size_t,chunk_t*))allocate_bytes;
|
||||
this->public.destroy = (void (*)(prf_plus_t *))destroy;
|
||||
|
||||
|
||||
/* take over prf */
|
||||
this->prf = prf;
|
||||
|
||||
|
||||
/* allocate buffer for prf output */
|
||||
this->buffer.len = prf->get_block_size(prf);
|
||||
this->buffer.ptr = malloc(this->buffer.len);
|
||||
|
||||
this->appending_octet = 0x01;
|
||||
|
||||
|
||||
/* clone seed */
|
||||
this->seed.ptr = clalloc(seed.ptr, seed.len);
|
||||
this->seed.len = seed.len;
|
||||
@@ -151,6 +151,6 @@ prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
|
||||
this->prf->get_bytes(this->prf, appending_chunk, this->buffer.ptr);
|
||||
this->given_out = 0;
|
||||
this->appending_octet++;
|
||||
|
||||
|
||||
return &(this->public);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup prf_plus prf_plus
|
||||
* @{ @ingroup crypto
|
||||
@@ -36,26 +36,26 @@ typedef struct prf_plus_t prf_plus_t;
|
||||
struct prf_plus_t {
|
||||
/**
|
||||
* Get pseudo random bytes.
|
||||
*
|
||||
*
|
||||
* Get the next few bytes of the prf+ output. Space
|
||||
* must be allocated by the caller.
|
||||
*
|
||||
*
|
||||
* @param length number of bytes to get
|
||||
* @param buffer pointer where the generated bytes will be written
|
||||
*/
|
||||
void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
|
||||
|
||||
|
||||
/**
|
||||
* Allocate pseudo random bytes.
|
||||
*
|
||||
*
|
||||
* Get the next few bytes of the prf+ output. This function
|
||||
* will allocate the required space.
|
||||
*
|
||||
*
|
||||
* @param length number of bytes to get
|
||||
* @param chunk chunk which will hold generated bytes
|
||||
*/
|
||||
void (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a prf_plus_t object.
|
||||
*/
|
||||
@@ -64,11 +64,11 @@ struct prf_plus_t {
|
||||
|
||||
/**
|
||||
* Creates a new prf_plus_t object.
|
||||
*
|
||||
*
|
||||
* Seed will be cloned. prf will
|
||||
* not be cloned, must be destroyed outside after
|
||||
* prf_plus_t usage.
|
||||
*
|
||||
*
|
||||
* @param prf prf object to use
|
||||
* @param seed input seed for prf
|
||||
* @return prf_plus_t object
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup prf prf
|
||||
* @{ @ingroup crypto
|
||||
@@ -55,7 +55,7 @@ enum pseudo_random_function_t {
|
||||
PRF_FIPS_SHA1_160 = 1025,
|
||||
/** FIPS 186-2-change1, uses fixed output size of 160bit */
|
||||
PRF_FIPS_DES = 1026,
|
||||
/**
|
||||
/**
|
||||
* Keyed hash algorithm using SHA1, used in EAP-AKA:
|
||||
* This PRF uses SHA1, but XORs the key into the IV. No "Final()" operation
|
||||
* is applied to the SHA1 state. */
|
||||
@@ -78,39 +78,39 @@ struct prf_t {
|
||||
* @param buffer pointer where the generated bytes will be written
|
||||
*/
|
||||
void (*get_bytes) (prf_t *this, chunk_t seed, u_int8_t *buffer);
|
||||
|
||||
|
||||
/**
|
||||
* Generates pseudo random bytes and allocate space for them.
|
||||
*
|
||||
*
|
||||
* @param seed a chunk containing the seed for the next bytes
|
||||
* @param chunk chunk which will hold generated bytes
|
||||
*/
|
||||
void (*allocate_bytes) (prf_t *this, chunk_t seed, chunk_t *chunk);
|
||||
|
||||
|
||||
/**
|
||||
* Get the block size of this prf_t object.
|
||||
*
|
||||
*
|
||||
* @return block size in bytes
|
||||
*/
|
||||
size_t (*get_block_size) (prf_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the key size of this prf_t object.
|
||||
*
|
||||
* This is a suggestion only, all implemented PRFs accept variable key
|
||||
* length.
|
||||
*
|
||||
*
|
||||
* @return key size in bytes
|
||||
*/
|
||||
size_t (*get_key_size) (prf_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Set the key for this prf_t object.
|
||||
*
|
||||
*
|
||||
* @param key key to set
|
||||
*/
|
||||
void (*set_key) (prf_t *this, chunk_t key);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a prf object.
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ struct proposal_token {
|
||||
char *name;
|
||||
transform_type_t type;
|
||||
u_int16_t algorithm;
|
||||
u_int16_t keysize;
|
||||
u_int16_t keysize;
|
||||
};
|
||||
|
||||
extern const proposal_token_t* proposal_get_token(register const char *str,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup rng rng
|
||||
* @{ @ingroup crypto
|
||||
@@ -55,15 +55,15 @@ struct rng_t {
|
||||
* @param buffer pointer where the generated bytes will be written
|
||||
*/
|
||||
void (*get_bytes) (rng_t *this, size_t len, u_int8_t *buffer);
|
||||
|
||||
|
||||
/**
|
||||
* Generates random bytes and allocate space for them.
|
||||
*
|
||||
*
|
||||
* @param len number of bytes to get
|
||||
* @param chunk chunk which will hold generated bytes
|
||||
*/
|
||||
void (*allocate_bytes) (rng_t *this, size_t len, chunk_t *chunk);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a rng object.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup signer signer
|
||||
* @{ @ingroup crypto
|
||||
@@ -80,53 +80,53 @@ struct signer_t {
|
||||
*
|
||||
* If buffer is NULL, data is processed and prepended to a next call until
|
||||
* buffer is a valid pointer.
|
||||
*
|
||||
*
|
||||
* @param data a chunk containing the data to sign
|
||||
* @param buffer pointer where the signature will be written
|
||||
*/
|
||||
void (*get_signature) (signer_t *this, chunk_t data, u_int8_t *buffer);
|
||||
|
||||
|
||||
/**
|
||||
* Generate a signature and allocate space for it.
|
||||
*
|
||||
* If chunk is NULL, data is processed and prepended to a next call until
|
||||
* chunk is a valid chunk pointer.
|
||||
*
|
||||
*
|
||||
* @param data a chunk containing the data to sign
|
||||
* @param chunk chunk which will hold the allocated signature
|
||||
*/
|
||||
void (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
|
||||
|
||||
|
||||
/**
|
||||
* Verify a signature.
|
||||
*
|
||||
*
|
||||
* @param data a chunk containing the data to verify
|
||||
* @param signature a chunk containing the signature
|
||||
* @return TRUE, if signature is valid, FALSE otherwise
|
||||
*/
|
||||
bool (*verify_signature) (signer_t *this, chunk_t data, chunk_t signature);
|
||||
|
||||
|
||||
/**
|
||||
* Get the block size of this signature algorithm.
|
||||
*
|
||||
*
|
||||
* @return block size in bytes
|
||||
*/
|
||||
size_t (*get_block_size) (signer_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the key size of the signature algorithm.
|
||||
*
|
||||
*
|
||||
* @return key size in bytes
|
||||
*/
|
||||
size_t (*get_key_size) (signer_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Set the key for this object.
|
||||
*
|
||||
*
|
||||
* @param key key to set
|
||||
*/
|
||||
void (*set_key) (signer_t *this, chunk_t key);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a signer_t object.
|
||||
*/
|
||||
|
||||
@@ -63,12 +63,12 @@ enum db_driver_t {
|
||||
char *atext;
|
||||
database_t *db;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
db = lib->database->create("mysql://user:pass@host/database");
|
||||
affected = db->execute(db, &rowid, "INSERT INTO table VALUES (?, ?)",
|
||||
DB_INT, 77, DB_TEXT, "a text");
|
||||
printf("inserted %d row, new row ID: %d\n", affected, rowid);
|
||||
|
||||
|
||||
enumerator = db->query(db, "SELECT aint, atext FROM table WHERE aint > ?",
|
||||
DB_INT, 10, // 1 argument to SQL string
|
||||
DB_INT, DB_TEXT); // 2 enumerated types in query
|
||||
@@ -83,7 +83,7 @@ enum db_driver_t {
|
||||
@endcode
|
||||
*/
|
||||
struct database_t {
|
||||
|
||||
|
||||
/**
|
||||
* Run a query which returns rows, such as a SELECT.
|
||||
*
|
||||
@@ -93,7 +93,7 @@ struct database_t {
|
||||
* @return enumerator as defined with arguments, NULL on failure
|
||||
*/
|
||||
enumerator_t* (*query)(database_t *this, char *sql, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Execute a query which dows not return rows, such as INSERT.
|
||||
*
|
||||
@@ -103,7 +103,7 @@ struct database_t {
|
||||
* @return number of affected rows, < 0 on failure
|
||||
*/
|
||||
int (*execute)(database_t *this, int *rowid, char *sql, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Get the database implementation type.
|
||||
*
|
||||
@@ -113,7 +113,7 @@ struct database_t {
|
||||
* @return database implementation type
|
||||
*/
|
||||
db_driver_t (*get_driver)(database_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a database connection.
|
||||
*/
|
||||
|
||||
@@ -29,12 +29,12 @@ struct private_database_factory_t {
|
||||
* public functions
|
||||
*/
|
||||
database_factory_t public;
|
||||
|
||||
|
||||
/**
|
||||
* list of registered database_t implementations
|
||||
*/
|
||||
linked_list_t *databases;
|
||||
|
||||
|
||||
/**
|
||||
* mutex to lock access to databases
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ static database_t* create(private_database_factory_t *this, char *uri)
|
||||
enumerator_t *enumerator;
|
||||
database_t *database = NULL;
|
||||
database_constructor_t create;
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->databases->create_enumerator(this->databases);
|
||||
while (enumerator->enumerate(enumerator, &create))
|
||||
@@ -103,15 +103,15 @@ static void destroy(private_database_factory_t *this)
|
||||
database_factory_t *database_factory_create()
|
||||
{
|
||||
private_database_factory_t *this = malloc_thing(private_database_factory_t);
|
||||
|
||||
|
||||
this->public.create = (database_t*(*)(database_factory_t*, char *url))create;
|
||||
this->public.add_database = (void(*)(database_factory_t*, database_constructor_t))add_database;
|
||||
this->public.remove_database = (void(*)(database_factory_t*, database_constructor_t))remove_database;
|
||||
this->public.destroy = (void(*)(database_factory_t*))destroy;
|
||||
|
||||
|
||||
this->databases = linked_list_create();
|
||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,21 +44,21 @@ struct database_factory_t {
|
||||
* @return database_t instance, NULL if not supported/failed
|
||||
*/
|
||||
database_t* (*create)(database_factory_t *this, char *uri);
|
||||
|
||||
|
||||
/**
|
||||
* Register a database constructor.
|
||||
*
|
||||
* @param create database constructor to register
|
||||
*/
|
||||
void (*add_database)(database_factory_t *this, database_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a previously registered database constructor.
|
||||
*
|
||||
* @param create database constructor to unregister
|
||||
*/
|
||||
void (*remove_database)(database_factory_t *this, database_constructor_t create);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a database_factory instance.
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@ void dbg_default(int level, char *fmt, ...)
|
||||
if (level <= 1)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup debug debug
|
||||
* @{ @ingroup libstrongswan
|
||||
|
||||
@@ -98,7 +98,7 @@ struct enum_name_t {
|
||||
*
|
||||
* This is a convenience macro to use when a enum_name list contains only
|
||||
* one range, and is equal as defining ENUM_BEGIN followed by ENUM_END.
|
||||
*
|
||||
*
|
||||
* @param name name of the enum_name list
|
||||
* @param first enum value of the first enum string
|
||||
* @param last enum value of the last enum string
|
||||
@@ -109,7 +109,7 @@ struct enum_name_t {
|
||||
/**
|
||||
* printf hook function for enum_names_t.
|
||||
*
|
||||
* Arguments are:
|
||||
* Arguments are:
|
||||
* enum_names_t *names, int value
|
||||
*/
|
||||
int enum_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
|
||||
@@ -33,36 +33,36 @@ typedef enum fetcher_option_t fetcher_option_t;
|
||||
*/
|
||||
enum fetcher_option_t {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Data to include in fetch request, e.g. on a HTTP post.
|
||||
* Additional argument is a chunk_t
|
||||
*/
|
||||
FETCH_REQUEST_DATA,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Mime-Type of data included in FETCH_REQUEST_DATA.
|
||||
* Additional argument is a char*.
|
||||
*/
|
||||
FETCH_REQUEST_TYPE,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* HTTP header to be sent with with the fetch request.
|
||||
* Additional argument is a char*.
|
||||
*/
|
||||
FETCH_REQUEST_HEADER,
|
||||
|
||||
/**
|
||||
/**
|
||||
* Use HTTP Version 1.0 instead of 1.1.
|
||||
* No additional argument is needed.
|
||||
*/
|
||||
FETCH_HTTP_VERSION_1_0,
|
||||
|
||||
/**
|
||||
/**
|
||||
* Timeout to use for fetch, in seconds.
|
||||
* Additional argument is u_int
|
||||
*/
|
||||
FETCH_TIMEOUT,
|
||||
|
||||
|
||||
/**
|
||||
* end of fetching options
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ struct fetcher_t {
|
||||
* - FAILED, NOT_FOUND, PARSE_ERROR on failure
|
||||
*/
|
||||
status_t (*fetch)(fetcher_t *this, char *uri, chunk_t *result);
|
||||
|
||||
|
||||
/**
|
||||
* Set a fetcher option, as defined in fetcher_option_t.
|
||||
*
|
||||
@@ -107,11 +107,11 @@ struct fetcher_t {
|
||||
* @return TRUE if option supported, FALSE otherwise
|
||||
*/
|
||||
bool (*set_option)(fetcher_t *this, fetcher_option_t option, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy the fetcher instance.
|
||||
*/
|
||||
void (*destroy)(fetcher_t *this);
|
||||
void (*destroy)(fetcher_t *this);
|
||||
};
|
||||
|
||||
#endif /** FETCHER_H_ @}*/
|
||||
|
||||
@@ -30,12 +30,12 @@ struct private_fetcher_manager_t {
|
||||
* public functions
|
||||
*/
|
||||
fetcher_manager_t public;
|
||||
|
||||
|
||||
/**
|
||||
* list of registered fetchers, as entry_t
|
||||
*/
|
||||
linked_list_t *fetchers;
|
||||
|
||||
|
||||
/**
|
||||
* read write lock to list
|
||||
*/
|
||||
@@ -68,7 +68,7 @@ static status_t fetch(private_fetcher_manager_t *this,
|
||||
status_t status = NOT_SUPPORTED;
|
||||
entry_t *entry;
|
||||
bool capable = FALSE;
|
||||
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->fetchers->create_enumerator(this->fetchers);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -119,7 +119,7 @@ static status_t fetch(private_fetcher_manager_t *this,
|
||||
fetcher->destroy(fetcher);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
status = fetcher->fetch(fetcher, url, response);
|
||||
fetcher->destroy(fetcher);
|
||||
/* try another fetcher only if this one does not support that URL */
|
||||
@@ -142,11 +142,11 @@ static status_t fetch(private_fetcher_manager_t *this,
|
||||
/**
|
||||
* Implementation of fetcher_manager_t.add_fetcher.
|
||||
*/
|
||||
static void add_fetcher(private_fetcher_manager_t *this,
|
||||
static void add_fetcher(private_fetcher_manager_t *this,
|
||||
fetcher_constructor_t create, char *url)
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->url = strdup(url);
|
||||
entry->create = create;
|
||||
|
||||
@@ -163,7 +163,7 @@ static void remove_fetcher(private_fetcher_manager_t *this,
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->fetchers->create_enumerator(this->fetchers);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -194,15 +194,15 @@ static void destroy(private_fetcher_manager_t *this)
|
||||
fetcher_manager_t *fetcher_manager_create()
|
||||
{
|
||||
private_fetcher_manager_t *this = malloc_thing(private_fetcher_manager_t);
|
||||
|
||||
|
||||
this->public.fetch = (status_t(*)(fetcher_manager_t*, char *url, chunk_t *response, ...))fetch;
|
||||
this->public.add_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t,char*))add_fetcher;
|
||||
this->public.remove_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t))remove_fetcher;
|
||||
this->public.destroy = (void(*)(fetcher_manager_t*))destroy;
|
||||
|
||||
|
||||
this->fetchers = linked_list_create();
|
||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,15 +51,15 @@ struct fetcher_manager_t {
|
||||
*/
|
||||
void (*add_fetcher)(fetcher_manager_t *this,
|
||||
fetcher_constructor_t constructor, char *url);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a previously registered fetcher implementation.
|
||||
*
|
||||
* @param constructor fetcher constructor function to unregister
|
||||
*/
|
||||
void (*remove_fetcher)(fetcher_manager_t *this,
|
||||
void (*remove_fetcher)(fetcher_manager_t *this,
|
||||
fetcher_constructor_t constructor);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a fetcher_manager instance.
|
||||
*/
|
||||
|
||||
@@ -35,22 +35,22 @@ typedef struct private_integrity_checker_t private_integrity_checker_t;
|
||||
* Private data of an integrity_checker_t object.
|
||||
*/
|
||||
struct private_integrity_checker_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public integrity_checker_t interface.
|
||||
*/
|
||||
integrity_checker_t public;
|
||||
|
||||
|
||||
/**
|
||||
* dlopen handle to checksum library
|
||||
*/
|
||||
void *handle;
|
||||
|
||||
|
||||
/**
|
||||
* checksum array
|
||||
*/
|
||||
integrity_checksum_t *checksums;
|
||||
|
||||
|
||||
/**
|
||||
* number of checksums in array
|
||||
*/
|
||||
@@ -68,21 +68,21 @@ static u_int32_t build_file(private_integrity_checker_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 0;
|
||||
}
|
||||
|
||||
|
||||
if (fstat(fd, &sb) == -1)
|
||||
{
|
||||
DBG1(" getting file size of '%s' failed: %s", file, strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
{
|
||||
@@ -91,13 +91,13 @@ static u_int32_t build_file(private_integrity_checker_t *this, char *file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
*len = sb.st_size;
|
||||
*len = sb.st_size;
|
||||
contents = chunk_create(addr, sb.st_size);
|
||||
checksum = chunk_hash(contents);
|
||||
|
||||
|
||||
munmap(addr, sb.st_size);
|
||||
close(fd);
|
||||
|
||||
|
||||
return checksum;
|
||||
}
|
||||
|
||||
@@ -116,11 +116,11 @@ static int callback(struct dl_phdr_info *dlpi, size_t size, Dl_info *dli)
|
||||
dlpi->dlpi_name && *dlpi->dlpi_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < dlpi->dlpi_phnum; i++)
|
||||
{
|
||||
const ElfW(Phdr) *sgmt = &dlpi->dlpi_phdr[i];
|
||||
|
||||
|
||||
/* we are interested in the executable LOAD segment */
|
||||
if (sgmt->p_type == PT_LOAD && (sgmt->p_flags & PF_X))
|
||||
{
|
||||
@@ -143,7 +143,7 @@ static u_int32_t build_segment(private_integrity_checker_t *this, void *sym,
|
||||
{
|
||||
chunk_t segment;
|
||||
Dl_info dli;
|
||||
|
||||
|
||||
if (dladdr(sym, &dli) == 0)
|
||||
{
|
||||
DBG1(" unable to locate symbol: %s", dlerror());
|
||||
@@ -155,7 +155,7 @@ static u_int32_t build_segment(private_integrity_checker_t *this, void *sym,
|
||||
DBG1(" executable section not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
segment = chunk_create(dli.dli_fbase, dli.dli_saddr - dli.dli_fbase);
|
||||
*len = segment.len;
|
||||
return chunk_hash(segment);
|
||||
@@ -168,7 +168,7 @@ static integrity_checksum_t *find_checksum(private_integrity_checker_t *this,
|
||||
char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < this->checksum_count; i++)
|
||||
{
|
||||
if (streq(this->checksums[i].name, name))
|
||||
@@ -188,7 +188,7 @@ static bool check_file(private_integrity_checker_t *this,
|
||||
integrity_checksum_t *cs;
|
||||
u_int32_t sum;
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
cs = find_checksum(this, name);
|
||||
if (!cs)
|
||||
{
|
||||
@@ -225,7 +225,7 @@ static bool check_segment(private_integrity_checker_t *this,
|
||||
integrity_checksum_t *cs;
|
||||
u_int32_t sum;
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
cs = find_checksum(this, name);
|
||||
if (!cs)
|
||||
{
|
||||
@@ -259,7 +259,7 @@ static bool check_segment(private_integrity_checker_t *this,
|
||||
static bool check(private_integrity_checker_t *this, char *name, void *sym)
|
||||
{
|
||||
Dl_info dli;
|
||||
|
||||
|
||||
if (dladdr(sym, &dli) == 0)
|
||||
{
|
||||
DBG1("unable to locate symbol: %s", dlerror());
|
||||
@@ -294,14 +294,14 @@ static void destroy(private_integrity_checker_t *this)
|
||||
integrity_checker_t *integrity_checker_create(char *checksum_library)
|
||||
{
|
||||
private_integrity_checker_t *this = malloc_thing(private_integrity_checker_t);
|
||||
|
||||
|
||||
this->public.check_file = (bool(*)(integrity_checker_t*, char *name, char *file))check_file;
|
||||
this->public.build_file = (u_int32_t(*)(integrity_checker_t*, char *file, size_t *len))build_file;
|
||||
this->public.check_segment = (bool(*)(integrity_checker_t*, char *name, void *sym))check_segment;
|
||||
this->public.build_segment = (u_int32_t(*)(integrity_checker_t*, void *sym, size_t *len))build_segment;
|
||||
this->public.check = (bool(*)(integrity_checker_t*, char *name, void *sym))check;
|
||||
this->public.destroy = (void(*)(integrity_checker_t*))destroy;
|
||||
|
||||
|
||||
this->checksum_count = 0;
|
||||
this->handle = NULL;
|
||||
if (checksum_library)
|
||||
@@ -310,7 +310,7 @@ integrity_checker_t *integrity_checker_create(char *checksum_library)
|
||||
if (this->handle)
|
||||
{
|
||||
int *checksum_count;
|
||||
|
||||
|
||||
this->checksums = dlsym(this->handle, "checksums");
|
||||
checksum_count = dlsym(this->handle, "checksum_count");
|
||||
if (this->checksums && checksum_count)
|
||||
|
||||
@@ -34,11 +34,11 @@ struct integrity_checksum_t {
|
||||
/* name of the checksum */
|
||||
char *name;
|
||||
/* size in bytes of the file on disk */
|
||||
size_t file_len;
|
||||
size_t file_len;
|
||||
/* checksum of the file on disk */
|
||||
u_int32_t file;
|
||||
/* size in bytes of executable segment in memory */
|
||||
size_t segment_len;
|
||||
size_t segment_len;
|
||||
/* checksum of the executable segment in memory */
|
||||
u_int32_t segment;
|
||||
};
|
||||
@@ -59,7 +59,7 @@ struct integrity_checker_t {
|
||||
* @return TRUE if integrity tested successfully
|
||||
*/
|
||||
bool (*check_file)(integrity_checker_t *this, char *name, char *file);
|
||||
|
||||
|
||||
/**
|
||||
* Build the integrity checksum of a file on disk.
|
||||
*
|
||||
@@ -68,7 +68,7 @@ struct integrity_checker_t {
|
||||
* @return checksum, 0 on error
|
||||
*/
|
||||
u_int32_t (*build_file)(integrity_checker_t *this, char *file, size_t *len);
|
||||
|
||||
|
||||
/**
|
||||
* Check the integrity of the code segment in memory.
|
||||
*
|
||||
@@ -85,7 +85,7 @@ struct integrity_checker_t {
|
||||
* @return checksum, 0 on error
|
||||
*/
|
||||
u_int32_t (*build_segment)(integrity_checker_t *this, void *sym, size_t *len);
|
||||
|
||||
|
||||
/**
|
||||
* Check both, on disk file integrity and loaded segment.
|
||||
*
|
||||
@@ -94,7 +94,7 @@ struct integrity_checker_t {
|
||||
* @return TRUE if integrity tested successfully
|
||||
*/
|
||||
bool (*check)(integrity_checker_t *this, char *name, void *sym);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a integrity_checker_t.
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,7 @@ void library_deinit()
|
||||
{
|
||||
this->public.integrity->destroy(this->public.integrity);
|
||||
}
|
||||
|
||||
|
||||
#ifdef LEAK_DETECTIVE
|
||||
if (this->detective)
|
||||
{
|
||||
@@ -92,16 +92,16 @@ bool library_init(char *settings)
|
||||
printf_hook_t *pfh;
|
||||
private_library_t *this = malloc_thing(private_library_t);
|
||||
lib = &this->public;
|
||||
|
||||
|
||||
lib->leak_detective = FALSE;
|
||||
|
||||
|
||||
#ifdef LEAK_DETECTIVE
|
||||
this->detective = leak_detective_create();
|
||||
#endif /* LEAK_DETECTIVE */
|
||||
|
||||
pfh = printf_hook_create();
|
||||
this->public.printf_hook = pfh;
|
||||
|
||||
|
||||
pfh->add_handler(pfh, 'b', mem_printf_hook,
|
||||
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,
|
||||
PRINTF_HOOK_ARGTYPE_END);
|
||||
@@ -120,7 +120,7 @@ bool library_init(char *settings)
|
||||
PRINTF_HOOK_ARGTYPE_END);
|
||||
pfh->add_handler(pfh, 'Y', identification_printf_hook,
|
||||
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_END);
|
||||
|
||||
|
||||
this->public.settings = settings_create(settings);
|
||||
this->public.crypto = crypto_factory_create();
|
||||
this->public.creds = credential_factory_create();
|
||||
@@ -129,7 +129,7 @@ bool library_init(char *settings)
|
||||
this->public.db = database_factory_create();
|
||||
this->public.plugins = plugin_loader_create();
|
||||
this->public.integrity = NULL;
|
||||
|
||||
|
||||
if (lib->settings->get_bool(lib->settings,
|
||||
"libstrongswan.integrity_test", FALSE))
|
||||
{
|
||||
|
||||
@@ -75,47 +75,47 @@ struct library_t {
|
||||
* Printf hook registering facility
|
||||
*/
|
||||
printf_hook_t *printf_hook;
|
||||
|
||||
|
||||
/**
|
||||
* crypto algorithm registry and factory
|
||||
*/
|
||||
crypto_factory_t *crypto;
|
||||
|
||||
|
||||
/**
|
||||
* credential constructor registry and factory
|
||||
*/
|
||||
credential_factory_t *creds;
|
||||
|
||||
|
||||
/**
|
||||
* key encoding registry and factory
|
||||
*/
|
||||
key_encoding_t *encoding;
|
||||
|
||||
|
||||
/**
|
||||
* URL fetching facility
|
||||
*/
|
||||
fetcher_manager_t *fetcher;
|
||||
|
||||
|
||||
/**
|
||||
* database construction factory
|
||||
*/
|
||||
database_factory_t *db;
|
||||
|
||||
|
||||
/**
|
||||
* plugin loading facility
|
||||
*/
|
||||
plugin_loader_t *plugins;
|
||||
|
||||
|
||||
/**
|
||||
* various settings loaded from settings file
|
||||
*/
|
||||
settings_t *settings;
|
||||
|
||||
|
||||
/**
|
||||
* integrity checker to verify code integrity
|
||||
*/
|
||||
integrity_checker_t *integrity;
|
||||
|
||||
|
||||
/**
|
||||
* is leak detective running?
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user