Lines Matching +full:- +full:e

1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2008-2015 Fuzhou Rockchip Electronics Co., Ltd
16 * \brief SHA-1 context structure
27 * 32-bit integer manipulation macros (big endian)
47 * SHA-1 context setup
52 ctx->total[0] = 0; in sha1_starts()
53 ctx->total[1] = 0; in sha1_starts()
55 ctx->state[0] = 0x67452301; in sha1_starts()
56 ctx->state[1] = 0xEFCDAB89; in sha1_starts()
57 ctx->state[2] = 0x98BADCFE; in sha1_starts()
58 ctx->state[3] = 0x10325476; in sha1_starts()
59 ctx->state[4] = 0xC3D2E1F0; in sha1_starts()
64 unsigned long temp, W[16], A, B, C, D, E; in sha1_process() local
83 #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) in sha1_process()
86 temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \ in sha1_process()
87 W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \ in sha1_process()
91 #define P(a,b,c,d,e,x) { \ in sha1_process() argument
92 e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ in sha1_process()
95 A = ctx->state[0]; in sha1_process()
96 B = ctx->state[1]; in sha1_process()
97 C = ctx->state[2]; in sha1_process()
98 D = ctx->state[3]; in sha1_process()
99 E = ctx->state[4]; in sha1_process()
104 P (A, B, C, D, E, W[0]); in sha1_process()
105 P (E, A, B, C, D, W[1]); in sha1_process()
106 P (D, E, A, B, C, W[2]); in sha1_process()
107 P (C, D, E, A, B, W[3]); in sha1_process()
108 P (B, C, D, E, A, W[4]); in sha1_process()
109 P (A, B, C, D, E, W[5]); in sha1_process()
110 P (E, A, B, C, D, W[6]); in sha1_process()
111 P (D, E, A, B, C, W[7]); in sha1_process()
112 P (C, D, E, A, B, W[8]); in sha1_process()
113 P (B, C, D, E, A, W[9]); in sha1_process()
114 P (A, B, C, D, E, W[10]); in sha1_process()
115 P (E, A, B, C, D, W[11]); in sha1_process()
116 P (D, E, A, B, C, W[12]); in sha1_process()
117 P (C, D, E, A, B, W[13]); in sha1_process()
118 P (B, C, D, E, A, W[14]); in sha1_process()
119 P (A, B, C, D, E, W[15]); in sha1_process()
120 P (E, A, B, C, D, R (16)); in sha1_process()
121 P (D, E, A, B, C, R (17)); in sha1_process()
122 P (C, D, E, A, B, R (18)); in sha1_process()
123 P (B, C, D, E, A, R (19)); in sha1_process()
131 P (A, B, C, D, E, R (20)); in sha1_process()
132 P (E, A, B, C, D, R (21)); in sha1_process()
133 P (D, E, A, B, C, R (22)); in sha1_process()
134 P (C, D, E, A, B, R (23)); in sha1_process()
135 P (B, C, D, E, A, R (24)); in sha1_process()
136 P (A, B, C, D, E, R (25)); in sha1_process()
137 P (E, A, B, C, D, R (26)); in sha1_process()
138 P (D, E, A, B, C, R (27)); in sha1_process()
139 P (C, D, E, A, B, R (28)); in sha1_process()
140 P (B, C, D, E, A, R (29)); in sha1_process()
141 P (A, B, C, D, E, R (30)); in sha1_process()
142 P (E, A, B, C, D, R (31)); in sha1_process()
143 P (D, E, A, B, C, R (32)); in sha1_process()
144 P (C, D, E, A, B, R (33)); in sha1_process()
145 P (B, C, D, E, A, R (34)); in sha1_process()
146 P (A, B, C, D, E, R (35)); in sha1_process()
147 P (E, A, B, C, D, R (36)); in sha1_process()
148 P (D, E, A, B, C, R (37)); in sha1_process()
149 P (C, D, E, A, B, R (38)); in sha1_process()
150 P (B, C, D, E, A, R (39)); in sha1_process()
158 P (A, B, C, D, E, R (40)); in sha1_process()
159 P (E, A, B, C, D, R (41)); in sha1_process()
160 P (D, E, A, B, C, R (42)); in sha1_process()
161 P (C, D, E, A, B, R (43)); in sha1_process()
162 P (B, C, D, E, A, R (44)); in sha1_process()
163 P (A, B, C, D, E, R (45)); in sha1_process()
164 P (E, A, B, C, D, R (46)); in sha1_process()
165 P (D, E, A, B, C, R (47)); in sha1_process()
166 P (C, D, E, A, B, R (48)); in sha1_process()
167 P (B, C, D, E, A, R (49)); in sha1_process()
168 P (A, B, C, D, E, R (50)); in sha1_process()
169 P (E, A, B, C, D, R (51)); in sha1_process()
170 P (D, E, A, B, C, R (52)); in sha1_process()
171 P (C, D, E, A, B, R (53)); in sha1_process()
172 P (B, C, D, E, A, R (54)); in sha1_process()
173 P (A, B, C, D, E, R (55)); in sha1_process()
174 P (E, A, B, C, D, R (56)); in sha1_process()
175 P (D, E, A, B, C, R (57)); in sha1_process()
176 P (C, D, E, A, B, R (58)); in sha1_process()
177 P (B, C, D, E, A, R (59)); in sha1_process()
185 P (A, B, C, D, E, R (60)); in sha1_process()
186 P (E, A, B, C, D, R (61)); in sha1_process()
187 P (D, E, A, B, C, R (62)); in sha1_process()
188 P (C, D, E, A, B, R (63)); in sha1_process()
189 P (B, C, D, E, A, R (64)); in sha1_process()
190 P (A, B, C, D, E, R (65)); in sha1_process()
191 P (E, A, B, C, D, R (66)); in sha1_process()
192 P (D, E, A, B, C, R (67)); in sha1_process()
193 P (C, D, E, A, B, R (68)); in sha1_process()
194 P (B, C, D, E, A, R (69)); in sha1_process()
195 P (A, B, C, D, E, R (70)); in sha1_process()
196 P (E, A, B, C, D, R (71)); in sha1_process()
197 P (D, E, A, B, C, R (72)); in sha1_process()
198 P (C, D, E, A, B, R (73)); in sha1_process()
199 P (B, C, D, E, A, R (74)); in sha1_process()
200 P (A, B, C, D, E, R (75)); in sha1_process()
201 P (E, A, B, C, D, R (76)); in sha1_process()
202 P (D, E, A, B, C, R (77)); in sha1_process()
203 P (C, D, E, A, B, R (78)); in sha1_process()
204 P (B, C, D, E, A, R (79)); in sha1_process()
209 ctx->state[0] += A; in sha1_process()
210 ctx->state[1] += B; in sha1_process()
211 ctx->state[2] += C; in sha1_process()
212 ctx->state[3] += D; in sha1_process()
213 ctx->state[4] += E; in sha1_process()
221 * SHA-1 process buffer
233 left = ctx->total[0] & 0x3F; in sha1_update()
234 fill = 64 - left; in sha1_update()
236 ctx->total[0] += ilen; in sha1_update()
237 ctx->total[0] &= 0xFFFFFFFF; in sha1_update()
239 if (ctx->total[0] < (unsigned long) ilen) in sha1_update()
240 ctx->total[1]++; in sha1_update()
243 memcpy ((void *) (ctx->buffer + left), (void *) input, fill); in sha1_update()
244 sha1_process (ctx, ctx->buffer); in sha1_update()
246 ilen -= fill; in sha1_update()
253 ilen -= 64; in sha1_update()
257 memcpy ((void *) (ctx->buffer + left), (void *) input, ilen); in sha1_update()
269 * SHA-1 final digest
278 high = (ctx->total[0] >> 29) in sha1_finish()
279 | (ctx->total[1] << 3); in sha1_finish()
280 low = (ctx->total[0] << 3); in sha1_finish()
285 last = ctx->total[0] & 0x3F; in sha1_finish()
286 padn = (last < 56) ? (56 - last) : (120 - last); in sha1_finish()
291 PUT_UINT32_BE (ctx->state[0], output, 0); in sha1_finish()
292 PUT_UINT32_BE (ctx->state[1], output, 4); in sha1_finish()
293 PUT_UINT32_BE (ctx->state[2], output, 8); in sha1_finish()
294 PUT_UINT32_BE (ctx->state[3], output, 12); in sha1_finish()
295 PUT_UINT32_BE (ctx->state[4], output, 16); in sha1_finish()
299 * Output = SHA-1( input buffer )
321 ctx->total[0] = 0; in sha256_starts()
322 ctx->total[1] = 0; in sha256_starts()
324 ctx->state[0] = 0x6A09E667; in sha256_starts()
325 ctx->state[1] = 0xBB67AE85; in sha256_starts()
326 ctx->state[2] = 0x3C6EF372; in sha256_starts()
327 ctx->state[3] = 0xA54FF53A; in sha256_starts()
328 ctx->state[4] = 0x510E527F; in sha256_starts()
329 ctx->state[5] = 0x9B05688C; in sha256_starts()
330 ctx->state[6] = 0x1F83D9AB; in sha256_starts()
331 ctx->state[7] = 0x5BE0CD19; in sha256_starts()
338 uint32_t A, B, C, D, E, F, G, H; in sha256_process() local
358 #define ROTR(x,n) (SHR(x,n) | (x << (32 - n))) in sha256_process()
371 W[t] = S1(W[t - 2]) + W[t - 7] + \ in sha256_process()
372 S0(W[t - 15]) + W[t - 16] \ in sha256_process()
375 #define P(a,b,c,d,e,f,g,h,x,K) { \ in sha256_process() argument
376 temp1 = h + S3(e) + F1(e,f,g) + K + x; \ in sha256_process()
381 A = ctx->state[0]; in sha256_process()
382 B = ctx->state[1]; in sha256_process()
383 C = ctx->state[2]; in sha256_process()
384 D = ctx->state[3]; in sha256_process()
385 E = ctx->state[4]; in sha256_process()
386 F = ctx->state[5]; in sha256_process()
387 G = ctx->state[6]; in sha256_process()
388 H = ctx->state[7]; in sha256_process()
390 P(A, B, C, D, E, F, G, H, W[0], 0x428A2F98); in sha256_process()
391 P(H, A, B, C, D, E, F, G, W[1], 0x71374491); in sha256_process()
392 P(G, H, A, B, C, D, E, F, W[2], 0xB5C0FBCF); in sha256_process()
393 P(F, G, H, A, B, C, D, E, W[3], 0xE9B5DBA5); in sha256_process()
394 P(E, F, G, H, A, B, C, D, W[4], 0x3956C25B); in sha256_process()
395 P(D, E, F, G, H, A, B, C, W[5], 0x59F111F1); in sha256_process()
396 P(C, D, E, F, G, H, A, B, W[6], 0x923F82A4); in sha256_process()
397 P(B, C, D, E, F, G, H, A, W[7], 0xAB1C5ED5); in sha256_process()
398 P(A, B, C, D, E, F, G, H, W[8], 0xD807AA98); in sha256_process()
399 P(H, A, B, C, D, E, F, G, W[9], 0x12835B01); in sha256_process()
400 P(G, H, A, B, C, D, E, F, W[10], 0x243185BE); in sha256_process()
401 P(F, G, H, A, B, C, D, E, W[11], 0x550C7DC3); in sha256_process()
402 P(E, F, G, H, A, B, C, D, W[12], 0x72BE5D74); in sha256_process()
403 P(D, E, F, G, H, A, B, C, W[13], 0x80DEB1FE); in sha256_process()
404 P(C, D, E, F, G, H, A, B, W[14], 0x9BDC06A7); in sha256_process()
405 P(B, C, D, E, F, G, H, A, W[15], 0xC19BF174); in sha256_process()
406 P(A, B, C, D, E, F, G, H, R(16), 0xE49B69C1); in sha256_process()
407 P(H, A, B, C, D, E, F, G, R(17), 0xEFBE4786); in sha256_process()
408 P(G, H, A, B, C, D, E, F, R(18), 0x0FC19DC6); in sha256_process()
409 P(F, G, H, A, B, C, D, E, R(19), 0x240CA1CC); in sha256_process()
410 P(E, F, G, H, A, B, C, D, R(20), 0x2DE92C6F); in sha256_process()
411 P(D, E, F, G, H, A, B, C, R(21), 0x4A7484AA); in sha256_process()
412 P(C, D, E, F, G, H, A, B, R(22), 0x5CB0A9DC); in sha256_process()
413 P(B, C, D, E, F, G, H, A, R(23), 0x76F988DA); in sha256_process()
414 P(A, B, C, D, E, F, G, H, R(24), 0x983E5152); in sha256_process()
415 P(H, A, B, C, D, E, F, G, R(25), 0xA831C66D); in sha256_process()
416 P(G, H, A, B, C, D, E, F, R(26), 0xB00327C8); in sha256_process()
417 P(F, G, H, A, B, C, D, E, R(27), 0xBF597FC7); in sha256_process()
418 P(E, F, G, H, A, B, C, D, R(28), 0xC6E00BF3); in sha256_process()
419 P(D, E, F, G, H, A, B, C, R(29), 0xD5A79147); in sha256_process()
420 P(C, D, E, F, G, H, A, B, R(30), 0x06CA6351); in sha256_process()
421 P(B, C, D, E, F, G, H, A, R(31), 0x14292967); in sha256_process()
422 P(A, B, C, D, E, F, G, H, R(32), 0x27B70A85); in sha256_process()
423 P(H, A, B, C, D, E, F, G, R(33), 0x2E1B2138); in sha256_process()
424 P(G, H, A, B, C, D, E, F, R(34), 0x4D2C6DFC); in sha256_process()
425 P(F, G, H, A, B, C, D, E, R(35), 0x53380D13); in sha256_process()
426 P(E, F, G, H, A, B, C, D, R(36), 0x650A7354); in sha256_process()
427 P(D, E, F, G, H, A, B, C, R(37), 0x766A0ABB); in sha256_process()
428 P(C, D, E, F, G, H, A, B, R(38), 0x81C2C92E); in sha256_process()
429 P(B, C, D, E, F, G, H, A, R(39), 0x92722C85); in sha256_process()
430 P(A, B, C, D, E, F, G, H, R(40), 0xA2BFE8A1); in sha256_process()
431 P(H, A, B, C, D, E, F, G, R(41), 0xA81A664B); in sha256_process()
432 P(G, H, A, B, C, D, E, F, R(42), 0xC24B8B70); in sha256_process()
433 P(F, G, H, A, B, C, D, E, R(43), 0xC76C51A3); in sha256_process()
434 P(E, F, G, H, A, B, C, D, R(44), 0xD192E819); in sha256_process()
435 P(D, E, F, G, H, A, B, C, R(45), 0xD6990624); in sha256_process()
436 P(C, D, E, F, G, H, A, B, R(46), 0xF40E3585); in sha256_process()
437 P(B, C, D, E, F, G, H, A, R(47), 0x106AA070); in sha256_process()
438 P(A, B, C, D, E, F, G, H, R(48), 0x19A4C116); in sha256_process()
439 P(H, A, B, C, D, E, F, G, R(49), 0x1E376C08); in sha256_process()
440 P(G, H, A, B, C, D, E, F, R(50), 0x2748774C); in sha256_process()
441 P(F, G, H, A, B, C, D, E, R(51), 0x34B0BCB5); in sha256_process()
442 P(E, F, G, H, A, B, C, D, R(52), 0x391C0CB3); in sha256_process()
443 P(D, E, F, G, H, A, B, C, R(53), 0x4ED8AA4A); in sha256_process()
444 P(C, D, E, F, G, H, A, B, R(54), 0x5B9CCA4F); in sha256_process()
445 P(B, C, D, E, F, G, H, A, R(55), 0x682E6FF3); in sha256_process()
446 P(A, B, C, D, E, F, G, H, R(56), 0x748F82EE); in sha256_process()
447 P(H, A, B, C, D, E, F, G, R(57), 0x78A5636F); in sha256_process()
448 P(G, H, A, B, C, D, E, F, R(58), 0x84C87814); in sha256_process()
449 P(F, G, H, A, B, C, D, E, R(59), 0x8CC70208); in sha256_process()
450 P(E, F, G, H, A, B, C, D, R(60), 0x90BEFFFA); in sha256_process()
451 P(D, E, F, G, H, A, B, C, R(61), 0xA4506CEB); in sha256_process()
452 P(C, D, E, F, G, H, A, B, R(62), 0xBEF9A3F7); in sha256_process()
453 P(B, C, D, E, F, G, H, A, R(63), 0xC67178F2); in sha256_process()
455 ctx->state[0] += A; in sha256_process()
456 ctx->state[1] += B; in sha256_process()
457 ctx->state[2] += C; in sha256_process()
458 ctx->state[3] += D; in sha256_process()
459 ctx->state[4] += E; in sha256_process()
460 ctx->state[5] += F; in sha256_process()
461 ctx->state[6] += G; in sha256_process()
462 ctx->state[7] += H; in sha256_process()
484 left = ctx->total[0] & 0x3F; in sha256_update()
485 fill = 64 - left; in sha256_update()
487 ctx->total[0] += length; in sha256_update()
488 ctx->total[0] &= 0xFFFFFFFF; in sha256_update()
490 if (ctx->total[0] < length) in sha256_update()
491 ctx->total[1]++; in sha256_update()
494 memcpy((void *) (ctx->buffer + left), (void *) input, fill); in sha256_update()
495 sha256_process(ctx, ctx->buffer); in sha256_update()
496 length -= fill; in sha256_update()
503 length -= 64; in sha256_update()
508 memcpy((void *) (ctx->buffer + left), (void *) input, length); in sha256_update()
525 high = ((ctx->total[0] >> 29) in sha256_finish()
526 | (ctx->total[1] << 3)); in sha256_finish()
527 low = (ctx->total[0] << 3); in sha256_finish()
532 last = ctx->total[0] & 0x3F; in sha256_finish()
533 padn = (last < 56) ? (56 - last) : (120 - last); in sha256_finish()
538 PUT_UINT32_BE(ctx->state[0], digest, 0); in sha256_finish()
539 PUT_UINT32_BE(ctx->state[1], digest, 4); in sha256_finish()
540 PUT_UINT32_BE(ctx->state[2], digest, 8); in sha256_finish()
541 PUT_UINT32_BE(ctx->state[3], digest, 12); in sha256_finish()
542 PUT_UINT32_BE(ctx->state[4], digest, 16); in sha256_finish()
543 PUT_UINT32_BE(ctx->state[5], digest, 20); in sha256_finish()
544 PUT_UINT32_BE(ctx->state[6], digest, 24); in sha256_finish()
545 PUT_UINT32_BE(ctx->state[7], digest, 28); in sha256_finish()
549 * Output = SHA-256( input buffer ).
572 fprintf(stderr, "E/%s(%d): " fmt "\n", __func__, __LINE__, ##args)
580 #define FDT_PATH "rk-kernel.dtb"
617 #define OPT_VERBOSE "--verbose"
618 #define OPT_HELP "--help"
619 #define OPT_VERSION "--version"
620 #define OPT_PRINT "--print"
621 #define OPT_PACK "--pack"
622 #define OPT_UNPACK "--unpack"
623 #define OPT_TEST_LOAD "--test_load"
624 #define OPT_TEST_CHARGE "--test_charge"
625 #define OPT_IMAGE "--image="
626 #define OPT_ROOT "--root="
628 #define VERSION "2014-5-31 14:43:42"
657 return (size + BLOCK_SIZE - 1) / BLOCK_SIZE; in fix_blocks()
695 header->resource_ptn_version = switch_short(header->resource_ptn_version); in fix_header()
696 header->index_tbl_version = switch_short(header->index_tbl_version); in fix_header()
697 header->tbl_entry_num = switch_int(header->tbl_entry_num); in fix_header()
703 entry->content_offset = switch_int(entry->content_offset); in fix_entry()
704 entry->content_size = switch_int(entry->content_size); in fix_entry()
784 return -1; in test_load()
791 argc--, argv++; in test_load()
795 argc--, argv++; in test_load()
805 if (content->load_addr) { in free_content()
806 free(content->load_addr); in free_content()
807 content->load_addr = 0; in free_content()
822 if (content->load_addr) in load_content()
824 int blocks = fix_blocks(content->content_size); in load_content()
825 content->load_addr = malloc(blocks * BLOCK_SIZE); in load_content()
826 if (!content->load_addr) in load_content()
828 if (!StorageReadLba(get_ptn_offset() + content->content_offset, in load_content()
829 content->load_addr, blocks)) { in load_content()
834 tests_dump_file(content->path, content->load_addr, content->content_size); in load_content()
841 if (!StorageReadLba(get_ptn_offset() + content->content_offset + offset_block, in load_content_data()
845 tests_dump_file(content->path, data, blocks * BLOCK_SIZE); in load_content_data()
887 if (memcmp(entry->tag, INDEX_TBL_ENTR_TAG, sizeof(entry->tag))) { in get_entry()
892 if (!strncmp(entry->path, file_path, sizeof(entry->path))) in get_entry()
902 printf("Found entry:\n\tpath:%s\n\toffset:%d\tsize:%d\n", entry->path, in get_entry()
903 entry->content_offset, entry->content_size); in get_entry()
914 if (!get_entry(content->path, &entry)) in get_content()
916 content->content_offset = entry.content_offset; in get_content()
917 content->content_size = entry.content_size; in get_content()
965 level_conf->max_level = atoi(buf + strlen(OPT_CHARGE_ANIM_LEVEL_CONF)); in parse_level_conf()
972 level_conf->num = atoi(buf + strlen(OPT_CHARGE_ANIM_LEVEL_NUM)); in parse_level_conf()
973 if (level_conf->num <= 0) { in parse_level_conf()
982 level_conf->delay = atoi(buf + strlen(OPT_CHARGE_ANIM_DELAY)); in parse_level_conf()
986 snprintf(level_conf->prefix, sizeof(level_conf->prefix), "%s", in parse_level_conf()
994 level_conf->max_level, level_conf->num, level_conf->delay, in parse_level_conf()
995 level_conf->prefix); in parse_level_conf()
1019 char *end = buf + content.content_size - 1; in test_charge()
1110 (i - j) * sizeof(anim_level_conf)); in test_charge()
1139 printf("%s (cjf@rock-chips.com)\t" VERSION "\n", PROG); in version()
1176 argc--, argv++; in main()
1177 while (argc > 0 && argv[0][0] == '-') { in main()
1180 argc--, argv++; in main()
1206 return -1; in main()
1236 return -1; in main()
1248 buf[pos - path] = '\0'; in mkdirs()
1300 len -= n; in dump_file()
1322 } else if (unpack_dir[strlen(unpack_dir) - 1] == '/') { in unpack_image()
1323 unpack_dir[strlen(unpack_dir) - 1] = '\0'; in unpack_image()
1391 return ret ? 0 : -1; in unpack_image()
1403 return -1; in get_file_size()
1414 int ret = -1; in write_file()
1512 if (!strcmp(files[i] + strlen(files[i]) - strlen(DTD_SUBFIX), DTD_SUBFIX)) { in write_index_tbl()
1515 LOGD("mod fdt path:%s -> %s...", files[i], FDT_PATH); in write_index_tbl()
1546 if (!strcmp(files[i] + strlen(files[i]) - strlen(DTD_SUBFIX), DTD_SUBFIX)) { in pack_image()
1554 tmp = files[file_num - 1]; in pack_image()
1555 files[file_num - 1] = files[i]; in pack_image()
1557 file_num--; in pack_image()
1572 return ret ? 0 : -1; in pack_image()