More cleanup, and fix SHA384 built-in C code.
This commit is contained in:
parent
91d0cbe892
commit
37047a39f9
9 changed files with 229 additions and 205 deletions
|
@ -74,7 +74,7 @@ typedef struct poly1305_state_internal_t {
|
|||
} poly1305_state_internal_t;
|
||||
|
||||
#if defined(ZT_NO_TYPE_PUNNING) || (__BYTE_ORDER != __LITTLE_ENDIAN)
|
||||
static inline unsigned long long U8TO64(const unsigned char *p)
|
||||
static ZT_ALWAYS_INLINE unsigned long long U8TO64(const unsigned char *p)
|
||||
{
|
||||
return
|
||||
(((unsigned long long)(p[0] & 0xff) ) |
|
||||
|
@ -91,7 +91,7 @@ static inline unsigned long long U8TO64(const unsigned char *p)
|
|||
#endif
|
||||
|
||||
#if defined(ZT_NO_TYPE_PUNNING) || (__BYTE_ORDER != __LITTLE_ENDIAN)
|
||||
static inline void U64TO8(unsigned char *p, unsigned long long v)
|
||||
static ZT_ALWAYS_INLINE void U64TO8(unsigned char *p, unsigned long long v)
|
||||
{
|
||||
p[0] = (v ) & 0xff;
|
||||
p[1] = (v >> 8) & 0xff;
|
||||
|
@ -106,7 +106,7 @@ static inline void U64TO8(unsigned char *p, unsigned long long v)
|
|||
#define U64TO8(p,v) ((*reinterpret_cast<unsigned long long *>(p)) = (v))
|
||||
#endif
|
||||
|
||||
static inline void poly1305_init(poly1305_context *ctx, const unsigned char key[32])
|
||||
static ZT_ALWAYS_INLINE void poly1305_init(poly1305_context *ctx, const unsigned char key[32])
|
||||
{
|
||||
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
||||
unsigned long long t0,t1;
|
||||
|
@ -132,7 +132,7 @@ static inline void poly1305_init(poly1305_context *ctx, const unsigned char key[
|
|||
st->final = 0;
|
||||
}
|
||||
|
||||
static inline void poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, size_t bytes)
|
||||
static ZT_ALWAYS_INLINE void poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, size_t bytes)
|
||||
{
|
||||
const unsigned long long hibit = (st->final) ? 0 : ((unsigned long long)1 << 40); /* 1 << 128 */
|
||||
unsigned long long r0,r1,r2;
|
||||
|
@ -183,7 +183,7 @@ static inline void poly1305_blocks(poly1305_state_internal_t *st, const unsigned
|
|||
st->h[2] = h2;
|
||||
}
|
||||
|
||||
static inline void poly1305_finish(poly1305_context *ctx, unsigned char mac[16])
|
||||
static ZT_ALWAYS_INLINE void poly1305_finish(poly1305_context *ctx, unsigned char mac[16])
|
||||
{
|
||||
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
||||
unsigned long long h0,h1,h2,c;
|
||||
|
@ -274,7 +274,7 @@ typedef struct poly1305_state_internal_t {
|
|||
} poly1305_state_internal_t;
|
||||
|
||||
/* interpret four 8 bit unsigned integers as a 32 bit unsigned integer in little endian */
|
||||
static unsigned long
|
||||
static ZT_ALWAYS_INLINE unsigned long
|
||||
U8TO32(const unsigned char *p) {
|
||||
return
|
||||
(((unsigned long)(p[0] & 0xff) ) |
|
||||
|
@ -284,7 +284,7 @@ U8TO32(const unsigned char *p) {
|
|||
}
|
||||
|
||||
/* store a 32 bit unsigned integer as four 8 bit unsigned integers in little endian */
|
||||
static void
|
||||
static ZT_ALWAYS_INLINE void
|
||||
U32TO8(unsigned char *p, unsigned long v) {
|
||||
p[0] = (v ) & 0xff;
|
||||
p[1] = (v >> 8) & 0xff;
|
||||
|
@ -292,7 +292,7 @@ U32TO8(unsigned char *p, unsigned long v) {
|
|||
p[3] = (v >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static ZT_ALWAYS_INLINE void
|
||||
poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
|
||||
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
||||
|
||||
|
@ -320,7 +320,7 @@ poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
|
|||
st->final = 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static ZT_ALWAYS_INLINE void
|
||||
poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, size_t bytes) {
|
||||
const unsigned long hibit = (st->final) ? 0 : (1 << 24); /* 1 << 128 */
|
||||
unsigned long r0,r1,r2,r3,r4;
|
||||
|
@ -379,7 +379,7 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, size_t by
|
|||
st->h[4] = h4;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static ZT_ALWAYS_INLINE void
|
||||
poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
|
||||
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
||||
unsigned long h0,h1,h2,h3,h4,c;
|
||||
|
@ -470,7 +470,7 @@ poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
|
|||
|
||||
#endif // MSC/GCC or not
|
||||
|
||||
static inline void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes) {
|
||||
static ZT_ALWAYS_INLINE void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes) {
|
||||
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
||||
size_t i;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue