added libtomcrypt-1.02

This commit is contained in:
Tom St Denis
2005-04-19 11:30:30 +00:00
committed by Steffen Jaeckel
parent 6ac9952498
commit 65c1317eee
14 changed files with 38 additions and 34 deletions
+1 -4
View File
@@ -101,13 +101,10 @@ int gcm_add_aad(gcm_state *gcm,
/* start adding AAD data to the state */
for (; x < adatalen; x++) {
gcm->buf[gcm->buflen++] = *adata++;
gcm->X[gcm->buflen++] ^= *adata++;
if (gcm->buflen == 16) {
/* GF mult it */
for (y = 0; y < 16; y++) {
gcm->X[y] ^= gcm->buf[y];
}
gcm_mult_h(gcm, gcm->X);
gcm->buflen = 0;
gcm->totlen += 128;
-3
View File
@@ -49,9 +49,6 @@ int gcm_done(gcm_state *gcm,
/* handle remaining ciphertext */
if (gcm->buflen) {
for (x = 0; x < (unsigned long)gcm->buflen; x++) {
gcm->X[x] ^= gcm->buf[x];
}
gcm->pttotlen += gcm->buflen * CONST64(8);
gcm_mult_h(gcm, gcm->X);
}
+5 -9
View File
@@ -36,8 +36,10 @@ int gcm_process(gcm_state *gcm,
int err;
LTC_ARGCHK(gcm != NULL);
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
if (ptlen > 0) {
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
}
if (gcm->buflen > 16 || gcm->buflen < 0) {
return CRYPT_INVALID_ARG;
@@ -51,9 +53,6 @@ int gcm_process(gcm_state *gcm,
if (gcm->mode == GCM_MODE_AAD) {
/* let's process the AAD */
if (gcm->buflen) {
for (x = 0; x < (unsigned long)gcm->buflen; x++) {
gcm->X[x] ^= gcm->buf[x];
}
gcm->totlen += gcm->buflen * CONST64(8);
gcm_mult_h(gcm, gcm->X);
}
@@ -115,9 +114,6 @@ int gcm_process(gcm_state *gcm,
/* process text */
for (; x < ptlen; x++) {
if (gcm->buflen == 16) {
for (y = 0; y < 16; y++) {
gcm->X[y] ^= gcm->buf[y];
}
gcm->pttotlen += 128;
gcm_mult_h(gcm, gcm->X);
@@ -135,7 +131,7 @@ int gcm_process(gcm_state *gcm,
b = ct[x];
pt[x] = ct[x] ^ gcm->buf[gcm->buflen];
}
gcm->buf[gcm->buflen++] = b;
gcm->X[gcm->buflen++] ^= b;
}
return CRYPT_OK;
+4
View File
@@ -23,6 +23,9 @@
*/
int gcm_test(void)
{
#ifndef LTC_TEST
return CRYPT_NOP;
#else
static const struct {
unsigned char K[32];
int keylen;
@@ -355,6 +358,7 @@ int gcm_test(void)
}
return CRYPT_OK;
#endif
}
#endif