asthetics

This commit is contained in:
JacobBarthelmeh
2014-07-17 15:33:48 -06:00
parent b77a1fdbbb
commit 7cb65d8b3d
2 changed files with 54 additions and 56 deletions

View File

@@ -4751,8 +4751,8 @@ static INLINE void AeadIncrementExpIV(CYASSL* ssl)
} }
} }
#ifdef HAVE_POLY1305
#ifdef HAVE_POLY1305
/*more recent rfc's concatonate input for poly1305 differently*/ /*more recent rfc's concatonate input for poly1305 differently*/
static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out, static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out,
byte* cipher, word16 sz, byte* tag) byte* cipher, word16 sz, byte* tag)
@@ -4780,7 +4780,7 @@ static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out,
if ((ret = Poly1305Update(ssl->encrypt.poly1305, out, msglen)) != 0) if ((ret = Poly1305Update(ssl->encrypt.poly1305, out, msglen)) != 0)
return ret; return ret;
/* handle padding for cipher input */ /* handle padding for cipher input to make it 16 bytes long */
if (msglen % 16 != 0) { if (msglen % 16 != 0) {
paddingSz = (16 - (sz - ssl->specs.aead_mac_size) % 16); paddingSz = (16 - (sz - ssl->specs.aead_mac_size) % 16);
if (paddingSz < 0) if (paddingSz < 0)
@@ -4800,7 +4800,6 @@ static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out,
padding[9] = (msglen >> 8) & 0xff; padding[9] = (msglen >> 8) & 0xff;
padding[10] = (msglen >>16) & 0xff; padding[10] = (msglen >>16) & 0xff;
padding[11] = (msglen >>24) & 0xff; padding[11] = (msglen >>24) & 0xff;
if ((ret = Poly1305Update(ssl->encrypt.poly1305, padding, sizeof(padding))) if ((ret = Poly1305Update(ssl->encrypt.poly1305, padding, sizeof(padding)))
!= 0) != 0)
return ret; return ret;
@@ -4812,9 +4811,8 @@ static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out,
return ret; return ret;
} }
/**
* Used for the older version of creating AEAD tags with Poly1305 /* Used for the older version of creating AEAD tags with Poly1305 */
*/
static int Poly1305TagOld(CYASSL* ssl, byte* additional, const byte* out, static int Poly1305TagOld(CYASSL* ssl, byte* additional, const byte* out,
byte* cipher, word16 sz, byte* tag) byte* cipher, word16 sz, byte* tag)
{ {
@@ -4870,6 +4868,7 @@ static int Poly1305TagOld(CYASSL* ssl, byte* additional, const byte* out,
} }
#endif /*HAVE_POLY1305*/ #endif /*HAVE_POLY1305*/
#ifdef HAVE_CHACHA #ifdef HAVE_CHACHA
static int ChachaAEADEncrypt(CYASSL* ssl, byte* out, const byte* input, static int ChachaAEADEncrypt(CYASSL* ssl, byte* out, const byte* input,
word16 sz) word16 sz)
@@ -4973,6 +4972,7 @@ static int ChachaAEADEncrypt(CYASSL* ssl, byte* out, const byte* input,
return ret; return ret;
} }
static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input, static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input,
word16 sz) word16 sz)
{ {
@@ -5016,7 +5016,6 @@ static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input,
c16toa(ssl->keys.dtls_state.curEpoch, additional); c16toa(ssl->keys.dtls_state.curEpoch, additional);
#endif #endif
#ifdef CHACHA_AEAD_TEST #ifdef CHACHA_AEAD_TEST
printf("Decrypt Additional : "); printf("Decrypt Additional : ");
for (i = 0; i < CHACHA20_BLOCK_SIZE; i++) { for (i = 0; i < CHACHA20_BLOCK_SIZE; i++) {
@@ -5066,7 +5065,6 @@ static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input,
sz - ssl->specs.aead_mac_size)) != 0) sz - ssl->specs.aead_mac_size)) != 0)
return ret; return ret;
#ifdef CHACHA_AEAD_TEST #ifdef CHACHA_AEAD_TEST
printf("plain after decrypt :\n"); printf("plain after decrypt :\n");
for (i = 0; i < sz; i++) { for (i = 0; i < sz; i++) {