[zeromq-dev] my minimal crypto_box / crypto_box_open test fails
Laurent Alebarde
l.alebarde at free.fr
Wed Oct 2 10:48:36 CEST 2013
I forgot to add the 16 authentication bytes in crypto_box :-[
Le 02/10/2013 10:37, Laurent Alebarde a écrit :
> I am trying to make working a minimal test of crypto_box /
> crypto_box_open, based on libzmq's curve_client.cpp :
>
> uint8_t k1_public [crypto_box_PUBLICKEYBYTES];
> uint8_t k1_secret [crypto_box_SECRETKEYBYTES];
> int rc = crypto_box_keypair (k1_public, k1_secret);
> uint8_t k2_public [crypto_box_PUBLICKEYBYTES];
> uint8_t k2_secret [crypto_box_SECRETKEYBYTES];
> rc = crypto_box_keypair (k2_public, k2_secret);
> uint8_t zeros [crypto_box_ZEROBYTES];
> memset (zeros, 0u, crypto_box_ZEROBYTES);
> uint8_t hello_plaintext1 [crypto_box_ZEROBYTES + 256];
> memset(hello_plaintext1, 0, crypto_box_ZEROBYTES);
> memset(hello_plaintext1 + crypto_box_ZEROBYTES, '_', 256);
> rc = memcmp(hello_plaintext1, zeros, crypto_box_ZEROBYTES);
> uint8_t hello_box0 [crypto_box_BOXZEROBYTES + 256];
> uint8_t hello_nonce0 [crypto_box_NONCEBYTES];
> memcpy (hello_nonce0, "abcdefghijklmnopqrstuvwx", 24);
> uint64_t nonce_val = 1;
> memcpy (hello_nonce0 + 16, &nonce_val, 8);
> rc = crypto_box (hello_box0, hello_plaintext1,
> sizeof hello_plaintext1,
> hello_nonce0, k2_public, k1_secret);
> uint8_t hello_plaintext2 [crypto_box_ZEROBYTES + 256];
> rc = memcmp(hello_box0, zeros, crypto_box_BOXZEROBYTES);
> rc = crypto_box_open (hello_plaintext2, hello_box0,
> sizeof hello_box0,
> hello_nonce0, k1_public, k2_secret);
> rc = memcmp(hello_plaintext1 + crypto_box_ZEROBYTES,
> hello_plaintext2 + crypto_box_ZEROBYTES, 256);
>
>
> It fails at crypto_box_open. In the debugger, all the prerequisites
> looks right. Could one tell me please what I am doing wrong ? I am on
> this since yesterday noon and it makes me crasy, though, it should be
> obvious.
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131002/97219075/attachment.htm>
More information about the zeromq-dev
mailing list