xref: /system/core/libmincrypt/sha.c
286void SHA_init(SHA_CTX* ctx) { 287 ctx->state[0] = 0x67452301; 288 ctx->state[1] = 0xEFCDAB89; 289 ctx->state[2] = 0x98BADCFE; 290 ctx->state[3] = 0x10325476; 291 ctx->state[4] = 0xC3D2E1F0; 292 ctx->count = 0; 293}
/system/core/include/mincrypt/sha.h
37typedef struct SHA_CTX { 38 uint64_t count; 39 uint32_t state[5]; 40#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) 41 union { 42 uint8_t b[64]; 43 uint32_t w[16]; 44 } buf; 45#else 46 uint8_t buf[64]; 47#endif 48} SHA_CTX;
xref: /system/core/libmincrypt/sha.c
147void SHA_update(SHA_CTX* ctx, const void* data, int len) { 148 int i = ctx->count % sizeof(ctx->buf); 149 const uint8_t* p = (const uint8_t*)data; 150 151 ctx->count += len; 152 153 while (len > sizeof(ctx->buf) - i) { 154 memcpy(&ctx->buf.b[i], p, sizeof(ctx->buf) - i); 155 len -= sizeof(ctx->buf) - i; 156 p += sizeof(ctx->buf) - i; 157 SHA1_Transform(ctx); 158 i = 0; 159 } 160 161 while (len--) { 162 ctx->buf.b[i++] = *p++; 163 if (i == sizeof(ctx->buf)) { 164 SHA1_Transform(ctx); 165 i = 0; 166 } 167 } 168}
'안드로이드 > 프레임워크' 카테고리의 다른 글
[안드로이드]Edify script (0) | 2014.01.06 |
---|---|
[퍼옴][안드로이드][프레임워크]Platform key signing 완벽 분석 (0) | 2014.01.06 |
[Android] OTA DownloadProvider document (0) | 2013.10.18 |
Bionic libc (3) (0) | 2012.11.08 |
Bionic libc (2) (0) | 2012.11.08 |