mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Consistent comment style
This commit is contained in:
@@ -64,17 +64,16 @@ extern "C" {
|
||||
|
||||
typedef struct blake2s_param_
|
||||
{
|
||||
uint8_t digest_length; // 1
|
||||
uint8_t key_length; // 2
|
||||
uint8_t fanout; // 3
|
||||
uint8_t depth; // 4
|
||||
uint8_t leaf_length[4]; // 8
|
||||
uint8_t node_offset[6];// 14
|
||||
uint8_t node_depth; // 15
|
||||
uint8_t inner_length; // 16
|
||||
// uint8_t reserved[0];
|
||||
uint8_t salt[BLAKE2S_SALTBYTES]; // 24
|
||||
uint8_t personal[BLAKE2S_PERSONALBYTES]; // 32
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint8_t leaf_length[4]; /* 8 */
|
||||
uint8_t node_offset[6]; /* 14 */
|
||||
uint8_t node_depth; /* 15 */
|
||||
uint8_t inner_length; /* 16 */
|
||||
uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */
|
||||
uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */
|
||||
} blake2s_param;
|
||||
|
||||
CRYPTO_ALIGN( 64 ) typedef struct blake2s_state_
|
||||
@@ -89,17 +88,17 @@ CRYPTO_ALIGN( 64 ) typedef struct blake2s_state_
|
||||
|
||||
typedef struct blake2b_param_
|
||||
{
|
||||
uint8_t digest_length; // 1
|
||||
uint8_t key_length; // 2
|
||||
uint8_t fanout; // 3
|
||||
uint8_t depth; // 4
|
||||
uint8_t leaf_length[4]; // 8
|
||||
uint8_t node_offset[8]; // 16
|
||||
uint8_t node_depth; // 17
|
||||
uint8_t inner_length; // 18
|
||||
uint8_t reserved[14]; // 32
|
||||
uint8_t salt[BLAKE2B_SALTBYTES]; // 48
|
||||
uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint8_t leaf_length[4]; /* 8 */
|
||||
uint8_t node_offset[8]; /* 16 */
|
||||
uint8_t node_depth; /* 17 */
|
||||
uint8_t inner_length; /* 18 */
|
||||
uint8_t reserved[14]; /* 32 */
|
||||
uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
|
||||
uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
|
||||
} blake2b_param;
|
||||
|
||||
#ifndef DEFINE_BLAKE2B_STATE
|
||||
@@ -138,7 +137,7 @@ CRYPTO_ALIGN( 64 ) typedef struct blake2b_state_
|
||||
# pragma pack(pop)
|
||||
#endif
|
||||
|
||||
// Streaming API
|
||||
/* Streaming API */
|
||||
int blake2s_init( blake2s_state *S, const uint8_t outlen );
|
||||
int blake2s_init_key( blake2s_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
|
||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
|
||||
@@ -165,7 +164,7 @@ CRYPTO_ALIGN( 64 ) typedef struct blake2b_state_
|
||||
int blake2bp_update( blake2bp_state *S, const uint8_t *in, uint64_t inlen );
|
||||
int blake2bp_final( blake2bp_state *S, uint8_t *out, uint8_t outlen );
|
||||
|
||||
// Simple API
|
||||
/* Simple API */
|
||||
int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
|
||||
int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
|
||||
int blake2b_salt_personal( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen, const void *salt, const void *personal );
|
||||
|
||||
@@ -84,7 +84,7 @@ static inline int blake2b_increment_counter( blake2b_state *S, const uint64_t in
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Parameter-related functions
|
||||
/* Parameter-related functions */
|
||||
#if 0
|
||||
static inline int blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length )
|
||||
{
|
||||
@@ -298,19 +298,19 @@ int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
memcpy( S->buf + left, in, fill ); // Fill buffer
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf ); // Compress
|
||||
memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); // Shift buffer left
|
||||
blake2b_compress( S, S->buf ); /* Compress */
|
||||
memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); /* Shift buffer left */
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else // inlen <= fill
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
memcpy( S->buf + left, in, inlen );
|
||||
S->buflen += inlen; // Be lazy, do not compress
|
||||
S->buflen += inlen; /* Be lazy, do not compress */
|
||||
in += inlen;
|
||||
inlen -= inlen;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@
|
||||
typedef uint8_t u8;
|
||||
typedef uint64_t limb;
|
||||
typedef limb felem[5];
|
||||
// This is a special gcc mode for 128-bit integers. It's implemented on 64-bit
|
||||
// platforms only as far as I know.
|
||||
/* Special gcc mode for 128-bit integers */
|
||||
typedef unsigned uint128_t __attribute__ ((mode(TI)));
|
||||
|
||||
/* Sum two numbers: output += in */
|
||||
@@ -315,7 +314,7 @@ fmonty(limb *x2, limb *z2, /* output 2Q */
|
||||
|
||||
memcpy(origx, x, 5 * sizeof(limb));
|
||||
fsum(x, z);
|
||||
fdifference_backwards(z, origx); // does x - z
|
||||
fdifference_backwards(z, origx); /* does x - z */
|
||||
|
||||
memcpy(origxprime, xprime, sizeof(limb) * 5);
|
||||
fsum(xprime, zprime);
|
||||
@@ -332,19 +331,19 @@ fmonty(limb *x2, limb *z2, /* output 2Q */
|
||||
fsquare_times(xx, x, 1);
|
||||
fsquare_times(zz, z, 1);
|
||||
fmul(x2, xx, zz);
|
||||
fdifference_backwards(zz, xx); // does zz = xx - zz
|
||||
fdifference_backwards(zz, xx); /* does zz = xx - zz */
|
||||
fscalar_product(zzz, zz, 121665);
|
||||
fsum(zzz, xx);
|
||||
fmul(z2, zz, zzz);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Maybe swap the contents of two limb arrays (@a and @b), each @len elements
|
||||
// long. Perform the swap iff @swap is non-zero.
|
||||
//
|
||||
// This function performs the swap without leaking any side-channel
|
||||
// information.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
Maybe swap the contents of two limb arrays (@a and @b), each @len elements
|
||||
long. Perform the swap iff @swap is non-zero.
|
||||
|
||||
This function performs the swap without leaking any side-channel
|
||||
information.
|
||||
----------------------------------------------------------------------------- */
|
||||
static void
|
||||
swap_conditional(limb a[5], limb b[5], limb iswap) {
|
||||
unsigned i;
|
||||
@@ -411,17 +410,17 @@ cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) {
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Shamelessly copied from djb's code, tightened a little
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
Shamelessly copied from djb's code, tightened a little
|
||||
----------------------------------------------------------------------------- */
|
||||
static void
|
||||
crecip(felem out, const felem z) {
|
||||
felem a,t0,b,c;
|
||||
|
||||
/* 2 */ fsquare_times(a, z, 1); // a = 2
|
||||
/* 2 */ fsquare_times(a, z, 1); /* a = 2 */
|
||||
/* 8 */ fsquare_times(t0, a, 2);
|
||||
/* 9 */ fmul(b, t0, z); // b = 9
|
||||
/* 11 */ fmul(a, b, a); // a = 11
|
||||
/* 9 */ fmul(b, t0, z); /* b = 9 */
|
||||
/* 11 */ fmul(a, b, a); /* a = 11 */
|
||||
/* 22 */ fsquare_times(t0, a, 1);
|
||||
/* 2^5 - 2^0 = 31 */ fmul(b, t0, b);
|
||||
/* 2^10 - 2^5 */ fsquare_times(t0, b, 5);
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
#define subc2 crypto_scalarmult_curve25519_sandy2x_subc2
|
||||
#define REDMASK51 crypto_scalarmult_curve25519_sandy2x_REDMASK51
|
||||
|
||||
#endif //ifndef consts_namespace_H
|
||||
#endif /* ifndef consts_namespace_H */
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@
|
||||
|
||||
#define fe51_invert crypto_scalarmult_curve25519_sandy2x_fe51_invert
|
||||
|
||||
#endif //ifndef fe51_namespace_H
|
||||
#endif /* ifndef fe51_namespace_H */
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ extern void ladder(fe *, const unsigned char *);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //ifndef ladder_H
|
||||
#endif /* ifndef ladder_H */
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ extern void ladder_base(fe *, const unsigned char *);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //ifndef ladder_base_H
|
||||
#endif /* ifndef ladder_base_H */
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
#define ladder_base crypto_scalarmult_curve25519_sandy2x_ladder_base
|
||||
#define _ladder_base _crypto_scalarmult_curve25519_sandy2x_ladder_base
|
||||
|
||||
#endif //ifndef ladder_base_namespace_H
|
||||
#endif /* ifndef ladder_base_namespace_H */
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
#define ladder crypto_scalarmult_curve25519_sandy2x_ladder
|
||||
#define _ladder _crypto_scalarmult_curve25519_sandy2x_ladder
|
||||
|
||||
#endif //ifndef ladder_namespace_H
|
||||
#endif /* ifndef ladder_namespace_H */
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ static const unsigned char nonce[24]
|
||||
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
|
||||
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
|
||||
|
||||
// API requires first 32 bytes to be 0
|
||||
/* API requires first 32 bytes to be 0 */
|
||||
static const unsigned char m[163]
|
||||
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ static unsigned char nonce[24]
|
||||
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
|
||||
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
|
||||
|
||||
// API requires first 16 bytes to be 0
|
||||
/* API requires first 16 bytes to be 0 */
|
||||
static unsigned char c[163]
|
||||
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
|
||||
|
||||
@@ -12,7 +12,7 @@ static unsigned char nonce[24]
|
||||
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
|
||||
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
|
||||
|
||||
// API requires first 32 bytes to be 0
|
||||
/* API requires first 32 bytes to be 0 */
|
||||
static unsigned char m[163]
|
||||
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
@@ -12,7 +12,7 @@ static unsigned char nonce[24]
|
||||
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
|
||||
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
|
||||
|
||||
// API requires first 16 bytes to be 0
|
||||
/* API requires first 16 bytes to be 0 */
|
||||
static unsigned char c[163]
|
||||
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
|
||||
|
||||
Reference in New Issue
Block a user