Mercurial > dropbear
comparison libtomcrypt/src/modes/ctr/ctr_encrypt.c @ 1437:871b18fd7065 fuzz
merge from main (libtommath/libtomcrypt/curve25510-donna updates)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 24 Jun 2017 22:51:45 +0800 |
parents | f849a5ca2efc |
children | 6dba84798cd5 |
comparison
equal
deleted
inserted
replaced
1432:41dca1e5ea34 | 1437:871b18fd7065 |
---|---|
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | 8 * |
9 * Tom St Denis, [email protected], http://libtomcrypt.com | 9 * Tom St Denis, [email protected], http://libtom.org |
10 */ | 10 */ |
11 #include "tomcrypt.h" | 11 #include "tomcrypt.h" |
12 | 12 |
13 /** | 13 /** |
14 @file ctr_encrypt.c | 14 @file ctr_encrypt.c |
62 /* is the pad empty? */ | 62 /* is the pad empty? */ |
63 if (ctr->padlen == ctr->blocklen) { | 63 if (ctr->padlen == ctr->blocklen) { |
64 /* increment counter */ | 64 /* increment counter */ |
65 if (ctr->mode == CTR_COUNTER_LITTLE_ENDIAN) { | 65 if (ctr->mode == CTR_COUNTER_LITTLE_ENDIAN) { |
66 /* little-endian */ | 66 /* little-endian */ |
67 for (x = 0; x < ctr->blocklen; x++) { | 67 for (x = 0; x < ctr->ctrlen; x++) { |
68 ctr->ctr[x] = (ctr->ctr[x] + (unsigned char)1) & (unsigned char)255; | 68 ctr->ctr[x] = (ctr->ctr[x] + (unsigned char)1) & (unsigned char)255; |
69 if (ctr->ctr[x] != (unsigned char)0) { | 69 if (ctr->ctr[x] != (unsigned char)0) { |
70 break; | 70 break; |
71 } | 71 } |
72 } | 72 } |
73 } else { | 73 } else { |
74 /* big-endian */ | 74 /* big-endian */ |
75 for (x = ctr->blocklen-1; x >= 0; x--) { | 75 for (x = ctr->blocklen-1; x >= ctr->ctrlen; x--) { |
76 ctr->ctr[x] = (ctr->ctr[x] + (unsigned char)1) & (unsigned char)255; | 76 ctr->ctr[x] = (ctr->ctr[x] + (unsigned char)1) & (unsigned char)255; |
77 if (ctr->ctr[x] != (unsigned char)0) { | 77 if (ctr->ctr[x] != (unsigned char)0) { |
78 break; | 78 break; |
79 } | 79 } |
80 } | 80 } |
105 return CRYPT_OK; | 105 return CRYPT_OK; |
106 } | 106 } |
107 | 107 |
108 #endif | 108 #endif |
109 | 109 |
110 /* $Source: /cvs/libtom/libtomcrypt/src/modes/ctr/ctr_encrypt.c,v $ */ | 110 /* $Source$ */ |
111 /* $Revision: 1.20 $ */ | 111 /* $Revision$ */ |
112 /* $Date: 2006/11/21 00:18:23 $ */ | 112 /* $Date$ */ |