Skip Menu |

This queue is for tickets about the Crypt-Sodium CPAN distribution.

Report information
The Basics
Id: 95987
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Crypt-Sodium

People
Owner: mike [...] mg2.org
Requestors: sgunderson [...] bigfoot.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: crypto_box() adds zero padding
Date: Mon, 26 May 2014 23:07:01 +0200
To: bug-Crypt-Sodium [...] rt.cpan.org
From: "Steinar H. Gunderson" <sgunderson [...] bigfoot.com>
Hi, It seems that crypto_box() adds a bunch of zero bytes that do not serve any obvious useful purpose. Example: cirkus:~> perl -le 'use Crypt::Sodium; $z = crypto_box("0123456789", "nnnnnnnnnnnnnnnnnnnnnnnn", "pppppppppppppppppppppppppppppppp", "ssssssssssssssssssssssssssssssss"); print unpack("H*", $z);' 00000000000000000000000000000000d1455f47cdc5f9cb6b3ea3dd2cb073a5a5cc3e149673e5a7965e which means there are 16 extra zero bytes at the start. The value afterwards (d1455f...) is indeed the correct output as produced by libnacl from C++. The padding is an artifact of the fact that the C library (as opposed to the C++ library) needs some temporary space for the Poly1305 cipher. http://nacl.cr.yp.to/box.html specifically says “Typical higher-level applications will work with the remaining bytes of the message”; in particular, it's not something that one should really transmit over the wire. Thus, it should probably be stripped away from the ciphertext before sending it on to the Perl program. /* Steinar */ -- Homepage: http://www.sesse.net/
Fixed in 0.05. Got rid of the nulls prefixed on the ciphertext as it comes out of crypto_box() before handing it over to the perl wrapper. This should just be a cosmetic fix. See also: https://github.com/mgregoro/Crypt-Sodium/commit/90ac624ed0dd0450b22a95a9254074eebc5d96f8