void Hacl_Hash_Lib_LoadStore_uint32s_to_be_bytes(uint8_t *output, uint32_t *input, uint32_t len) { for (uint32_t i = (uint32_t )0; i < len; i = i + (uint32_t )1) { uint32_t hd1 = input[i]; uint8_t *x0 = output + (uint32_t )4 * i; store32_be(x0, hd1); } }
int decrypt_string (const char *key, const char *str, char *dest, int len) { BF_KEY bf_key; uint32_t v; size_t i; /* Pad encoded string with 0 bits in case it's bogus */ if (!key || !key[0]) return 0; /* length must be a multiple of BF_BLOCK encoded in base64 */ if (len % (BF_BLOCK * 6 / 4) != 0) return 0; BF_set_key (&bf_key, strlen (key), (const unsigned char *) key); while (len > 0) { unsigned char block[BF_BLOCK] = { 0 }; for (i = v = 0; i < 6; ++i) v |= base64dec (*str++) << (i * 6); store32_be (block + 4, v); for (i = v = 0; i < 6; ++i) v |= base64dec (*str++) << (i * 6); store32_be (block + 0, v); BF_ecb_encrypt (block, block, &bf_key, BF_DECRYPT); memcpy (dest, block, BF_BLOCK); dest += BF_BLOCK; len -= BF_BLOCK * 6 / 4; } *dest++ = 0; return 1; }