| 111 | #endif |
| 112 | |
| 113 | LOCAL void |
| 114 | chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes) |
| 115 | { |
| 116 | u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; |
| 117 | u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15; |
| 118 | u8 *ctarget = NULL; |
| 119 | u8 tmp[64]; |
| 120 | u_int i; |
| 121 | |
| 122 | if (!bytes) return; |
| 123 | |
| 124 | j0 = x->input[0]; |
| 125 | j1 = x->input[1]; |
| 126 | j2 = x->input[2]; |
| 127 | j3 = x->input[3]; |
| 128 | j4 = x->input[4]; |
| 129 | j5 = x->input[5]; |
| 130 | j6 = x->input[6]; |
| 131 | j7 = x->input[7]; |
| 132 | j8 = x->input[8]; |
| 133 | j9 = x->input[9]; |
| 134 | j10 = x->input[10]; |
| 135 | j11 = x->input[11]; |
| 136 | j12 = x->input[12]; |
| 137 | j13 = x->input[13]; |
| 138 | j14 = x->input[14]; |
| 139 | j15 = x->input[15]; |
| 140 | |
| 141 | for (;;) { |
| 142 | if (bytes < 64) { |
| 143 | #ifndef KEYSTREAM_ONLY |
| 144 | for (i = 0;i < bytes;++i) tmp[i] = m[i]; |
| 145 | m = tmp; |
| 146 | #endif |
| 147 | ctarget = c; |
| 148 | c = tmp; |
| 149 | } |
| 150 | x0 = j0; |
| 151 | x1 = j1; |
| 152 | x2 = j2; |
| 153 | x3 = j3; |
| 154 | x4 = j4; |
| 155 | x5 = j5; |
| 156 | x6 = j6; |
| 157 | x7 = j7; |
| 158 | x8 = j8; |
| 159 | x9 = j9; |
| 160 | x10 = j10; |
| 161 | x11 = j11; |
| 162 | x12 = j12; |
| 163 | x13 = j13; |
| 164 | x14 = j14; |
| 165 | x15 = j15; |
| 166 | for (i = 20;i > 0;i -= 2) { |
| 167 | QUARTERROUND( x0, x4, x8,x12) |
| 168 | QUARTERROUND( x1, x5, x9,x13) |
| 169 | QUARTERROUND( x2, x6,x10,x14) |
| 170 | QUARTERROUND( x3, x7,x11,x15) |
no outgoing calls
no test coverage detected