Kinson Chik | a8fa74c | 2011-07-29 11:33:41 -0700 | [diff] [blame] | 1 | .text |
| 2 | |
| 3 | .global sha1_block_data_order |
| 4 | .type sha1_block_data_order,%function |
| 5 | |
| 6 | .align 2 |
| 7 | sha1_block_data_order: |
| 8 | stmdb sp!,{r4-r12,lr} |
| 9 | add r2,r1,r2,lsl#6 @ r2 to point at the end of r1 |
| 10 | ldmia r0,{r3,r4,r5,r6,r7} |
| 11 | .Lloop: |
| 12 | ldr r8,.LK_00_19 |
| 13 | mov r14,sp |
| 14 | sub sp,sp,#15*4 |
| 15 | mov r5,r5,ror#30 |
| 16 | mov r6,r6,ror#30 |
| 17 | mov r7,r7,ror#30 @ [6] |
| 18 | .L_00_15: |
| 19 | ldrb r9,[r1],#4 |
| 20 | ldrb r10,[r1,#-3] |
| 21 | ldrb r11,[r1,#-2] |
| 22 | ldrb r12,[r1,#-1] |
| 23 | add r7,r8,r7,ror#2 @ E+=K_00_19 |
| 24 | orr r9,r10,r9,lsl#8 |
| 25 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) |
| 26 | orr r9,r11,r9,lsl#8 |
| 27 | eor r10,r5,r6 @ F_xx_xx |
| 28 | orr r9,r12,r9,lsl#8 |
| 29 | add r7,r7,r9 @ E+=X[i] |
| 30 | str r9,[r14,#-4]! |
| 31 | and r10,r4,r10,ror#2 |
| 32 | eor r10,r10,r6,ror#2 @ F_00_19(B,C,D) |
| 33 | add r7,r7,r10 @ E+=F_00_19(B,C,D) |
| 34 | ldrb r9,[r1],#4 |
| 35 | ldrb r10,[r1,#-3] |
| 36 | ldrb r11,[r1,#-2] |
| 37 | ldrb r12,[r1,#-1] |
| 38 | add r6,r8,r6,ror#2 @ E+=K_00_19 |
| 39 | orr r9,r10,r9,lsl#8 |
| 40 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) |
| 41 | orr r9,r11,r9,lsl#8 |
| 42 | eor r10,r4,r5 @ F_xx_xx |
| 43 | orr r9,r12,r9,lsl#8 |
| 44 | add r6,r6,r9 @ E+=X[i] |
| 45 | str r9,[r14,#-4]! |
| 46 | and r10,r3,r10,ror#2 |
| 47 | eor r10,r10,r5,ror#2 @ F_00_19(B,C,D) |
| 48 | add r6,r6,r10 @ E+=F_00_19(B,C,D) |
| 49 | ldrb r9,[r1],#4 |
| 50 | ldrb r10,[r1,#-3] |
| 51 | ldrb r11,[r1,#-2] |
| 52 | ldrb r12,[r1,#-1] |
| 53 | add r5,r8,r5,ror#2 @ E+=K_00_19 |
| 54 | orr r9,r10,r9,lsl#8 |
| 55 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) |
| 56 | orr r9,r11,r9,lsl#8 |
| 57 | eor r10,r3,r4 @ F_xx_xx |
| 58 | orr r9,r12,r9,lsl#8 |
| 59 | add r5,r5,r9 @ E+=X[i] |
| 60 | str r9,[r14,#-4]! |
| 61 | and r10,r7,r10,ror#2 |
| 62 | eor r10,r10,r4,ror#2 @ F_00_19(B,C,D) |
| 63 | add r5,r5,r10 @ E+=F_00_19(B,C,D) |
| 64 | ldrb r9,[r1],#4 |
| 65 | ldrb r10,[r1,#-3] |
| 66 | ldrb r11,[r1,#-2] |
| 67 | ldrb r12,[r1,#-1] |
| 68 | add r4,r8,r4,ror#2 @ E+=K_00_19 |
| 69 | orr r9,r10,r9,lsl#8 |
| 70 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) |
| 71 | orr r9,r11,r9,lsl#8 |
| 72 | eor r10,r7,r3 @ F_xx_xx |
| 73 | orr r9,r12,r9,lsl#8 |
| 74 | add r4,r4,r9 @ E+=X[i] |
| 75 | str r9,[r14,#-4]! |
| 76 | and r10,r6,r10,ror#2 |
| 77 | eor r10,r10,r3,ror#2 @ F_00_19(B,C,D) |
| 78 | add r4,r4,r10 @ E+=F_00_19(B,C,D) |
| 79 | ldrb r9,[r1],#4 |
| 80 | ldrb r10,[r1,#-3] |
| 81 | ldrb r11,[r1,#-2] |
| 82 | ldrb r12,[r1,#-1] |
| 83 | add r3,r8,r3,ror#2 @ E+=K_00_19 |
| 84 | orr r9,r10,r9,lsl#8 |
| 85 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) |
| 86 | orr r9,r11,r9,lsl#8 |
| 87 | eor r10,r6,r7 @ F_xx_xx |
| 88 | orr r9,r12,r9,lsl#8 |
| 89 | add r3,r3,r9 @ E+=X[i] |
| 90 | str r9,[r14,#-4]! |
| 91 | and r10,r5,r10,ror#2 |
| 92 | eor r10,r10,r7,ror#2 @ F_00_19(B,C,D) |
| 93 | add r3,r3,r10 @ E+=F_00_19(B,C,D) |
| 94 | teq r14,sp |
| 95 | bne .L_00_15 @ [((11+4)*5+2)*3] |
| 96 | ldrb r9,[r1],#4 |
| 97 | ldrb r10,[r1,#-3] |
| 98 | ldrb r11,[r1,#-2] |
| 99 | ldrb r12,[r1,#-1] |
| 100 | add r7,r8,r7,ror#2 @ E+=K_00_19 |
| 101 | orr r9,r10,r9,lsl#8 |
| 102 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) |
| 103 | orr r9,r11,r9,lsl#8 |
| 104 | eor r10,r5,r6 @ F_xx_xx |
| 105 | orr r9,r12,r9,lsl#8 |
| 106 | add r7,r7,r9 @ E+=X[i] |
| 107 | str r9,[r14,#-4]! |
| 108 | and r10,r4,r10,ror#2 |
| 109 | eor r10,r10,r6,ror#2 @ F_00_19(B,C,D) |
| 110 | add r7,r7,r10 @ E+=F_00_19(B,C,D) |
| 111 | ldr r9,[r14,#15*4] |
| 112 | ldr r10,[r14,#13*4] |
| 113 | ldr r11,[r14,#7*4] |
| 114 | ldr r12,[r14,#2*4] |
| 115 | add r6,r8,r6,ror#2 @ E+=K_xx_xx |
| 116 | eor r9,r9,r10 |
| 117 | eor r9,r9,r11 |
| 118 | eor r9,r9,r12 |
| 119 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) |
| 120 | eor r10,r4,r5 @ F_xx_xx, but not in 40_59 |
| 121 | mov r9,r9,ror#31 |
| 122 | add r6,r6,r9 @ E+=X[i] |
| 123 | str r9,[r14,#-4]! |
| 124 | and r10,r3,r10,ror#2 |
| 125 | eor r10,r10,r5,ror#2 @ F_00_19(B,C,D) |
| 126 | add r6,r6,r10 @ E+=F_00_19(B,C,D) |
| 127 | ldr r9,[r14,#15*4] |
| 128 | ldr r10,[r14,#13*4] |
| 129 | ldr r11,[r14,#7*4] |
| 130 | ldr r12,[r14,#2*4] |
| 131 | add r5,r8,r5,ror#2 @ E+=K_xx_xx |
| 132 | eor r9,r9,r10 |
| 133 | eor r9,r9,r11 |
| 134 | eor r9,r9,r12 |
| 135 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) |
| 136 | eor r10,r3,r4 @ F_xx_xx, but not in 40_59 |
| 137 | mov r9,r9,ror#31 |
| 138 | add r5,r5,r9 @ E+=X[i] |
| 139 | str r9,[r14,#-4]! |
| 140 | and r10,r7,r10,ror#2 |
| 141 | eor r10,r10,r4,ror#2 @ F_00_19(B,C,D) |
| 142 | add r5,r5,r10 @ E+=F_00_19(B,C,D) |
| 143 | ldr r9,[r14,#15*4] |
| 144 | ldr r10,[r14,#13*4] |
| 145 | ldr r11,[r14,#7*4] |
| 146 | ldr r12,[r14,#2*4] |
| 147 | add r4,r8,r4,ror#2 @ E+=K_xx_xx |
| 148 | eor r9,r9,r10 |
| 149 | eor r9,r9,r11 |
| 150 | eor r9,r9,r12 |
| 151 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) |
| 152 | eor r10,r7,r3 @ F_xx_xx, but not in 40_59 |
| 153 | mov r9,r9,ror#31 |
| 154 | add r4,r4,r9 @ E+=X[i] |
| 155 | str r9,[r14,#-4]! |
| 156 | and r10,r6,r10,ror#2 |
| 157 | eor r10,r10,r3,ror#2 @ F_00_19(B,C,D) |
| 158 | add r4,r4,r10 @ E+=F_00_19(B,C,D) |
| 159 | ldr r9,[r14,#15*4] |
| 160 | ldr r10,[r14,#13*4] |
| 161 | ldr r11,[r14,#7*4] |
| 162 | ldr r12,[r14,#2*4] |
| 163 | add r3,r8,r3,ror#2 @ E+=K_xx_xx |
| 164 | eor r9,r9,r10 |
| 165 | eor r9,r9,r11 |
| 166 | eor r9,r9,r12 |
| 167 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) |
| 168 | eor r10,r6,r7 @ F_xx_xx, but not in 40_59 |
| 169 | mov r9,r9,ror#31 |
| 170 | add r3,r3,r9 @ E+=X[i] |
| 171 | str r9,[r14,#-4]! |
| 172 | and r10,r5,r10,ror#2 |
| 173 | eor r10,r10,r7,ror#2 @ F_00_19(B,C,D) |
| 174 | add r3,r3,r10 @ E+=F_00_19(B,C,D) |
| 175 | |
| 176 | ldr r8,.LK_20_39 @ [+15+16*4] |
| 177 | sub sp,sp,#25*4 |
| 178 | cmn sp,#0 @ [+3], clear carry to denote 20_39 |
| 179 | .L_20_39_or_60_79: |
| 180 | ldr r9,[r14,#15*4] |
| 181 | ldr r10,[r14,#13*4] |
| 182 | ldr r11,[r14,#7*4] |
| 183 | ldr r12,[r14,#2*4] |
| 184 | add r7,r8,r7,ror#2 @ E+=K_xx_xx |
| 185 | eor r9,r9,r10 |
| 186 | eor r9,r9,r11 |
| 187 | eor r9,r9,r12 |
| 188 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) |
| 189 | eor r10,r5,r6 @ F_xx_xx, but not in 40_59 |
| 190 | mov r9,r9,ror#31 |
| 191 | add r7,r7,r9 @ E+=X[i] |
| 192 | str r9,[r14,#-4]! |
| 193 | eor r10,r4,r10,ror#2 @ F_20_39(B,C,D) |
| 194 | add r7,r7,r10 @ E+=F_20_39(B,C,D) |
| 195 | ldr r9,[r14,#15*4] |
| 196 | ldr r10,[r14,#13*4] |
| 197 | ldr r11,[r14,#7*4] |
| 198 | ldr r12,[r14,#2*4] |
| 199 | add r6,r8,r6,ror#2 @ E+=K_xx_xx |
| 200 | eor r9,r9,r10 |
| 201 | eor r9,r9,r11 |
| 202 | eor r9,r9,r12 |
| 203 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) |
| 204 | eor r10,r4,r5 @ F_xx_xx, but not in 40_59 |
| 205 | mov r9,r9,ror#31 |
| 206 | add r6,r6,r9 @ E+=X[i] |
| 207 | str r9,[r14,#-4]! |
| 208 | eor r10,r3,r10,ror#2 @ F_20_39(B,C,D) |
| 209 | add r6,r6,r10 @ E+=F_20_39(B,C,D) |
| 210 | ldr r9,[r14,#15*4] |
| 211 | ldr r10,[r14,#13*4] |
| 212 | ldr r11,[r14,#7*4] |
| 213 | ldr r12,[r14,#2*4] |
| 214 | add r5,r8,r5,ror#2 @ E+=K_xx_xx |
| 215 | eor r9,r9,r10 |
| 216 | eor r9,r9,r11 |
| 217 | eor r9,r9,r12 |
| 218 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) |
| 219 | eor r10,r3,r4 @ F_xx_xx, but not in 40_59 |
| 220 | mov r9,r9,ror#31 |
| 221 | add r5,r5,r9 @ E+=X[i] |
| 222 | str r9,[r14,#-4]! |
| 223 | eor r10,r7,r10,ror#2 @ F_20_39(B,C,D) |
| 224 | add r5,r5,r10 @ E+=F_20_39(B,C,D) |
| 225 | ldr r9,[r14,#15*4] |
| 226 | ldr r10,[r14,#13*4] |
| 227 | ldr r11,[r14,#7*4] |
| 228 | ldr r12,[r14,#2*4] |
| 229 | add r4,r8,r4,ror#2 @ E+=K_xx_xx |
| 230 | eor r9,r9,r10 |
| 231 | eor r9,r9,r11 |
| 232 | eor r9,r9,r12 |
| 233 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) |
| 234 | eor r10,r7,r3 @ F_xx_xx, but not in 40_59 |
| 235 | mov r9,r9,ror#31 |
| 236 | add r4,r4,r9 @ E+=X[i] |
| 237 | str r9,[r14,#-4]! |
| 238 | eor r10,r6,r10,ror#2 @ F_20_39(B,C,D) |
| 239 | add r4,r4,r10 @ E+=F_20_39(B,C,D) |
| 240 | ldr r9,[r14,#15*4] |
| 241 | ldr r10,[r14,#13*4] |
| 242 | ldr r11,[r14,#7*4] |
| 243 | ldr r12,[r14,#2*4] |
| 244 | add r3,r8,r3,ror#2 @ E+=K_xx_xx |
| 245 | eor r9,r9,r10 |
| 246 | eor r9,r9,r11 |
| 247 | eor r9,r9,r12 |
| 248 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) |
| 249 | eor r10,r6,r7 @ F_xx_xx, but not in 40_59 |
| 250 | mov r9,r9,ror#31 |
| 251 | add r3,r3,r9 @ E+=X[i] |
| 252 | str r9,[r14,#-4]! |
| 253 | eor r10,r5,r10,ror#2 @ F_20_39(B,C,D) |
| 254 | add r3,r3,r10 @ E+=F_20_39(B,C,D) |
| 255 | teq r14,sp @ preserve carry |
| 256 | bne .L_20_39_or_60_79 @ [+((12+3)*5+2)*4] |
| 257 | bcs .L_done @ [+((12+3)*5+2)*4], spare 300 bytes |
| 258 | |
| 259 | ldr r8,.LK_40_59 |
| 260 | sub sp,sp,#20*4 @ [+2] |
| 261 | .L_40_59: |
| 262 | ldr r9,[r14,#15*4] |
| 263 | ldr r10,[r14,#13*4] |
| 264 | ldr r11,[r14,#7*4] |
| 265 | ldr r12,[r14,#2*4] |
| 266 | add r7,r8,r7,ror#2 @ E+=K_xx_xx |
| 267 | eor r9,r9,r10 |
| 268 | eor r9,r9,r11 |
| 269 | eor r9,r9,r12 |
| 270 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) |
| 271 | mov r9,r9,ror#31 |
| 272 | add r7,r7,r9 @ E+=X[i] |
| 273 | str r9,[r14,#-4]! |
| 274 | and r10,r4,r5,ror#2 |
| 275 | orr r11,r4,r5,ror#2 |
| 276 | and r11,r11,r6,ror#2 |
| 277 | orr r10,r10,r11 @ F_40_59(B,C,D) |
| 278 | add r7,r7,r10 @ E+=F_40_59(B,C,D) |
| 279 | ldr r9,[r14,#15*4] |
| 280 | ldr r10,[r14,#13*4] |
| 281 | ldr r11,[r14,#7*4] |
| 282 | ldr r12,[r14,#2*4] |
| 283 | add r6,r8,r6,ror#2 @ E+=K_xx_xx |
| 284 | eor r9,r9,r10 |
| 285 | eor r9,r9,r11 |
| 286 | eor r9,r9,r12 |
| 287 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) |
| 288 | mov r9,r9,ror#31 |
| 289 | add r6,r6,r9 @ E+=X[i] |
| 290 | str r9,[r14,#-4]! |
| 291 | and r10,r3,r4,ror#2 |
| 292 | orr r11,r3,r4,ror#2 |
| 293 | and r11,r11,r5,ror#2 |
| 294 | orr r10,r10,r11 @ F_40_59(B,C,D) |
| 295 | add r6,r6,r10 @ E+=F_40_59(B,C,D) |
| 296 | ldr r9,[r14,#15*4] |
| 297 | ldr r10,[r14,#13*4] |
| 298 | ldr r11,[r14,#7*4] |
| 299 | ldr r12,[r14,#2*4] |
| 300 | add r5,r8,r5,ror#2 @ E+=K_xx_xx |
| 301 | eor r9,r9,r10 |
| 302 | eor r9,r9,r11 |
| 303 | eor r9,r9,r12 |
| 304 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) |
| 305 | mov r9,r9,ror#31 |
| 306 | add r5,r5,r9 @ E+=X[i] |
| 307 | str r9,[r14,#-4]! |
| 308 | and r10,r7,r3,ror#2 |
| 309 | orr r11,r7,r3,ror#2 |
| 310 | and r11,r11,r4,ror#2 |
| 311 | orr r10,r10,r11 @ F_40_59(B,C,D) |
| 312 | add r5,r5,r10 @ E+=F_40_59(B,C,D) |
| 313 | ldr r9,[r14,#15*4] |
| 314 | ldr r10,[r14,#13*4] |
| 315 | ldr r11,[r14,#7*4] |
| 316 | ldr r12,[r14,#2*4] |
| 317 | add r4,r8,r4,ror#2 @ E+=K_xx_xx |
| 318 | eor r9,r9,r10 |
| 319 | eor r9,r9,r11 |
| 320 | eor r9,r9,r12 |
| 321 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) |
| 322 | mov r9,r9,ror#31 |
| 323 | add r4,r4,r9 @ E+=X[i] |
| 324 | str r9,[r14,#-4]! |
| 325 | and r10,r6,r7,ror#2 |
| 326 | orr r11,r6,r7,ror#2 |
| 327 | and r11,r11,r3,ror#2 |
| 328 | orr r10,r10,r11 @ F_40_59(B,C,D) |
| 329 | add r4,r4,r10 @ E+=F_40_59(B,C,D) |
| 330 | ldr r9,[r14,#15*4] |
| 331 | ldr r10,[r14,#13*4] |
| 332 | ldr r11,[r14,#7*4] |
| 333 | ldr r12,[r14,#2*4] |
| 334 | add r3,r8,r3,ror#2 @ E+=K_xx_xx |
| 335 | eor r9,r9,r10 |
| 336 | eor r9,r9,r11 |
| 337 | eor r9,r9,r12 |
| 338 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) |
| 339 | mov r9,r9,ror#31 |
| 340 | add r3,r3,r9 @ E+=X[i] |
| 341 | str r9,[r14,#-4]! |
| 342 | and r10,r5,r6,ror#2 |
| 343 | orr r11,r5,r6,ror#2 |
| 344 | and r11,r11,r7,ror#2 |
| 345 | orr r10,r10,r11 @ F_40_59(B,C,D) |
| 346 | add r3,r3,r10 @ E+=F_40_59(B,C,D) |
| 347 | teq r14,sp |
| 348 | bne .L_40_59 @ [+((12+5)*5+2)*4] |
| 349 | |
| 350 | ldr r8,.LK_60_79 |
| 351 | sub sp,sp,#20*4 |
| 352 | cmp sp,#0 @ set carry to denote 60_79 |
| 353 | b .L_20_39_or_60_79 @ [+4], spare 300 bytes |
| 354 | .L_done: |
| 355 | add sp,sp,#80*4 @ "deallocate" stack frame |
| 356 | ldmia r0,{r8,r9,r10,r11,r12} |
| 357 | add r3,r8,r3 |
| 358 | add r4,r9,r4 |
| 359 | add r5,r10,r5,ror#2 |
| 360 | add r6,r11,r6,ror#2 |
| 361 | add r7,r12,r7,ror#2 |
| 362 | stmia r0,{r3,r4,r5,r6,r7} |
| 363 | teq r1,r2 |
| 364 | bne .Lloop @ [+18], total 1307 |
| 365 | |
| 366 | ldmia sp!,{r4-r12,lr} |
| 367 | tst lr,#1 |
| 368 | moveq pc,lr @ be binary compatible with V4, yet |
| 369 | .word 0xe12fff1e @ interoperable with Thumb ISA:-) |
| 370 | .align 2 |
| 371 | .LK_00_19: .word 0x5a827999 |
| 372 | .LK_20_39: .word 0x6ed9eba1 |
| 373 | .LK_40_59: .word 0x8f1bbcdc |
| 374 | .LK_60_79: .word 0xca62c1d6 |
| 375 | .size sha1_block_data_order,.-sha1_block_data_order |
| 376 | .asciz "SHA1 block transform for ARMv4, CRYPTOGAMS by <appro@openssl.org>" |
| 377 | .align 2 |