Esempio n. 1
0
int
macaroon_secretbox(const unsigned char* enc_key,
                   const unsigned char* enc_nonce,
                   const unsigned char* plaintext, size_t plaintext_sz,
                   unsigned char* ciphertext)
{
    return crypto_secretbox_xsalsa20poly1305(ciphertext, plaintext, plaintext_sz, enc_nonce, enc_key);
}
Esempio n. 2
0
SODIUM_EXPORT int
crypto_secretbox_xsalsa20poly1305_ref(unsigned char *c,
                                      const unsigned char *m,
                                      unsigned long long mlen,
                                      const unsigned char *n,
                                      const unsigned char *k)
{
    return crypto_secretbox_xsalsa20poly1305(c, m, mlen, n, k);
}
int
crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
                                              const unsigned char *m,
                                              unsigned long long mlen,
                                              const unsigned char *n,
                                              const unsigned char *k)
{
    return crypto_secretbox_xsalsa20poly1305(c, m, mlen, n, k);
}
Esempio n. 4
0
main()
{
  int i;
  crypto_secretbox_xsalsa20poly1305(
    c,m,163,nonce,firstkey
  );
  for (i = 16;i < 163;++i) {
    printf(",0x%02x",(unsigned int) c[i]);
    if (i % 8 == 7) printf("\n");
  }
  printf("\n");
  return 0;
}
Esempio n. 5
0
File: reop.c Progetto: jwilkins/reop
/*
 * wrapper around crypto_secretbox.
 * operates on buf "in place".
 * box will be used to hold the additional auth tag data.
 */
static void
symencryptmsg(uint8_t *buf, unsigned long long msglen, uint8_t *box, uint8_t *symkey)
{
	uint8_t *cmsg, *msg;

	randombytes(box, SYMNONCEBYTES);

	msg = xmalloc(msglen + SYMZEROBYTES);
	memset(msg, 0, SYMZEROBYTES);
	memcpy(msg + SYMZEROBYTES, buf, msglen);
	cmsg = xmalloc(msglen + SYMZEROBYTES);

	crypto_secretbox_xsalsa20poly1305(cmsg, msg, msglen + SYMZEROBYTES,
	    box, symkey);
	xfree(msg, msglen + SYMZEROBYTES);

	memcpy(box + SYMNONCEBYTES, cmsg + SYMBOXZEROBYTES, SYMBOXBYTES);
	memcpy(buf, cmsg + SYMZEROBYTES, msglen);
	xfree(cmsg, msglen + SYMZEROBYTES);
}