upstream: https://github.com/mirage/mirage-crypto
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

disable sha512_init_t for now

fixup truncated-512-init not to use sprintf

pqwy a45ea6aa 06b62edb

+51 -50
+50 -49
src/native/hash/sha512.c
··· 194 194 p[i] = cpu_to_be64(ctx->h[i]); 195 195 } 196 196 197 - #include <stdio.h> 198 - 199 - void nc_sha512_init_t(struct sha512_ctx *ctx, int t) 200 - { 201 - memset(ctx, 0, sizeof(*ctx)); 202 - if (t >= 512) 203 - return; 204 - 205 - switch (t) { 206 - case 224: 207 - ctx->h[0] = 0x8c3d37c819544da2ULL; 208 - ctx->h[1] = 0x73e1996689dcd4d6ULL; 209 - ctx->h[2] = 0x1dfab7ae32ff9c82ULL; 210 - ctx->h[3] = 0x679dd514582f9fcfULL; 211 - ctx->h[4] = 0x0f6d2b697bd44da8ULL; 212 - ctx->h[5] = 0x77e36f7304c48942ULL; 213 - ctx->h[6] = 0x3f9d85a86a1d36c8ULL; 214 - ctx->h[7] = 0x1112e6ad91d692a1ULL; 215 - break; 216 - case 256: 217 - ctx->h[0] = 0x22312194fc2bf72cULL; 218 - ctx->h[1] = 0x9f555fa3c84c64c2ULL; 219 - ctx->h[2] = 0x2393b86b6f53b151ULL; 220 - ctx->h[3] = 0x963877195940eabdULL; 221 - ctx->h[4] = 0x96283ee2a88effe3ULL; 222 - ctx->h[5] = 0xbe5e1e2553863992ULL; 223 - ctx->h[6] = 0x2b0199fc2c85b8aaULL; 224 - ctx->h[7] = 0x0eb72ddc81c52ca2ULL; 225 - break; 226 - default: { 227 - uint8_t buf[8+4]; 228 - uint8_t out[64]; 229 - int i; 230 - 231 - nc_sha512_init(ctx); 232 - for (i = 0; i < 8; i++) 233 - ctx->h[i] ^= 0xa5a5a5a5a5a5a5a5ULL; 234 - 235 - i = sprintf((char *)buf, "SHA-512/%d", t); 236 - nc_sha512_update(ctx, buf, i); 237 - nc_sha512_finalize(ctx, out); 238 - 239 - /* re-init the context, otherwise len is changed */ 240 - memset(ctx, 0, sizeof(*ctx)); 241 - for (i = 0; i < 8; i++) 242 - ctx->h[i] = cpu_to_be64(((uint64_t *) out)[i]); 243 - } 244 - } 245 - } 197 + // // i don't wanna go to libc i said no no no 198 + // #include <stdio.h> 199 + // 200 + // void nc_sha512_init_t(struct sha512_ctx *ctx, int t) 201 + // { 202 + // memset(ctx, 0, sizeof(*ctx)); 203 + // if (t >= 512) 204 + // return; 205 + // 206 + // switch (t) { 207 + // case 224: 208 + // ctx->h[0] = 0x8c3d37c819544da2ULL; 209 + // ctx->h[1] = 0x73e1996689dcd4d6ULL; 210 + // ctx->h[2] = 0x1dfab7ae32ff9c82ULL; 211 + // ctx->h[3] = 0x679dd514582f9fcfULL; 212 + // ctx->h[4] = 0x0f6d2b697bd44da8ULL; 213 + // ctx->h[5] = 0x77e36f7304c48942ULL; 214 + // ctx->h[6] = 0x3f9d85a86a1d36c8ULL; 215 + // ctx->h[7] = 0x1112e6ad91d692a1ULL; 216 + // break; 217 + // case 256: 218 + // ctx->h[0] = 0x22312194fc2bf72cULL; 219 + // ctx->h[1] = 0x9f555fa3c84c64c2ULL; 220 + // ctx->h[2] = 0x2393b86b6f53b151ULL; 221 + // ctx->h[3] = 0x963877195940eabdULL; 222 + // ctx->h[4] = 0x96283ee2a88effe3ULL; 223 + // ctx->h[5] = 0xbe5e1e2553863992ULL; 224 + // ctx->h[6] = 0x2b0199fc2c85b8aaULL; 225 + // ctx->h[7] = 0x0eb72ddc81c52ca2ULL; 226 + // break; 227 + // default: { 228 + // uint8_t buf[8+4]; 229 + // uint8_t out[64]; 230 + // int i; 231 + // 232 + // nc_sha512_init(ctx); 233 + // for (i = 0; i < 8; i++) 234 + // ctx->h[i] ^= 0xa5a5a5a5a5a5a5a5ULL; 235 + // 236 + // i = sprintf((char *)buf, "SHA-512/%d", t); 237 + // nc_sha512_update(ctx, buf, i); 238 + // nc_sha512_finalize(ctx, out); 239 + // 240 + // /* re-init the context, otherwise len is changed */ 241 + // memset(ctx, 0, sizeof(*ctx)); 242 + // for (i = 0; i < 8; i++) 243 + // ctx->h[i] = cpu_to_be64(((uint64_t *) out)[i]); 244 + // } 245 + // } 246 + // }
+1 -1
src/native/hash/sha512.h
··· 49 49 void nc_sha512_update(struct sha512_ctx *ctx, uint8_t *data, uint32_t len); 50 50 void nc_sha512_finalize(struct sha512_ctx *ctx, uint8_t *out); 51 51 52 - void nc_sha512_init_t(struct sha512_ctx *ctx, int t); 52 + /* void nc_sha512_init_t(struct sha512_ctx *ctx, int t); */ 53 53 54 54 #endif