| 67 | } |
| 68 | |
| 69 | static void le64_nonce(unsigned char *npub, u64 nonce) |
| 70 | { |
| 71 | /* BOLT #8: |
| 72 | * |
| 73 | * ...with nonce `n` encoded as 32 zero bits, followed by a |
| 74 | * *little-endian* 64-bit value. Note: this follows the Noise Protocol |
| 75 | * convention, rather than our normal endian |
| 76 | */ |
| 77 | le64 le_nonce = cpu_to_le64(nonce); |
| 78 | const size_t zerolen = crypto_aead_chacha20poly1305_ietf_NPUBBYTES - sizeof(le_nonce); |
| 79 | |
| 80 | BUILD_ASSERT(crypto_aead_chacha20poly1305_ietf_NPUBBYTES >= sizeof(le_nonce)); |
| 81 | /* First part is 0, followed by nonce. */ |
| 82 | memset(npub, 0, zerolen); |
| 83 | memcpy(npub + zerolen, &le_nonce, sizeof(le_nonce)); |
| 84 | } |
| 85 | |
| 86 | u8 *cryptomsg_decrypt_body(const tal_t *ctx, |
| 87 | struct crypto_state *cs, const u8 *in) |
no test coverage detected