Function open [src]

Verify and decrypt c using a nonce npub and a key k. m must be exactly tag_length smaller than c, as c includes an authentication tag in addition to the encrypted message.

Prototype

pub fn open(m: []u8, c: []const u8, npub: [nonce_length]u8, k: [key_length]u8) AuthenticationError!void

Parameters

m: []u8c: []const u8npub: [nonce_length]u8k: [key_length]u8

Possible Errors

AuthenticationFailed AuthenticationError

Source

pub fn open(m: []u8, c: []const u8, npub: [nonce_length]u8, k: [key_length]u8) AuthenticationError!void { if (c.len < tag_length) { return error.AuthenticationFailed; } debug.assert(m.len == c.len - tag_length); return XSalsa20Poly1305.decrypt(m, c[tag_length..], c[0..tag_length].*, "", npub, k); }