Mercurial > dropbear
comparison ocb_init.c @ 143:5d99163f7e32 libtomcrypt-orig
import of libtomcrypt 0.99
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 19 Dec 2004 11:34:45 +0000 |
parents | 7faae8f46238 |
children |
comparison
equal
deleted
inserted
replaced
15:6362d3854bb4 | 143:5d99163f7e32 |
---|---|
71 ocb->R[x] = ocb->L[x] ^ nonce[x]; | 71 ocb->R[x] = ocb->L[x] ^ nonce[x]; |
72 } | 72 } |
73 cipher_descriptor[cipher].ecb_encrypt(ocb->R, ocb->R, &ocb->key); | 73 cipher_descriptor[cipher].ecb_encrypt(ocb->R, ocb->R, &ocb->key); |
74 | 74 |
75 /* find Ls[i] = L << i for i == 0..31 */ | 75 /* find Ls[i] = L << i for i == 0..31 */ |
76 memcpy(ocb->Ls[0], ocb->L, ocb->block_len); | 76 XMEMCPY(ocb->Ls[0], ocb->L, ocb->block_len); |
77 for (x = 1; x < 32; x++) { | 77 for (x = 1; x < 32; x++) { |
78 m = ocb->Ls[x-1][0] >> 7; | 78 m = ocb->Ls[x-1][0] >> 7; |
79 for (y = 0; y < ocb->block_len-1; y++) { | 79 for (y = 0; y < ocb->block_len-1; y++) { |
80 ocb->Ls[x][y] = ((ocb->Ls[x-1][y] << 1) | (ocb->Ls[x-1][y+1] >> 7)) & 255; | 80 ocb->Ls[x][y] = ((ocb->Ls[x-1][y] << 1) | (ocb->Ls[x-1][y+1] >> 7)) & 255; |
81 } | 81 } |
102 ocb->Lr[x] ^= polys[poly].poly_div[x]; | 102 ocb->Lr[x] ^= polys[poly].poly_div[x]; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 /* set Li, checksum */ | 106 /* set Li, checksum */ |
107 zeromem(ocb->Li, ocb->block_len); | 107 zeromem(ocb->Li, ocb->block_len); |
108 zeromem(ocb->checksum, ocb->block_len); | 108 zeromem(ocb->checksum, ocb->block_len); |
109 | 109 |
110 /* set other params */ | 110 /* set other params */ |
111 ocb->block_index = 1; | 111 ocb->block_index = 1; |
112 ocb->cipher = cipher; | 112 ocb->cipher = cipher; |