]> source.dussan.org Git - rspamd.git/commitdiff
Do not pad encrypted messages.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 28 Jan 2015 21:39:18 +0000 (21:39 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 28 Jan 2015 21:39:18 +0000 (21:39 +0000)
contrib/tweetnacl/tweetnacl.c
contrib/tweetnacl/tweetnacl.h

index feec43f35d292990d3b7f4091add061d9969b1d4..4e07b5fcf350adb23cfb36593c2eca6871ffb264 100644 (file)
@@ -246,10 +246,11 @@ int crypto_onetimeauth_verify(const u8 *h,const u8 *m,u64 n,const u8 *k)
 int crypto_secretbox(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k)
 {
   unsigned int i;
-  if (d < 32) return -1;
+  if (d < crypto_box_ZEROBYTES) return -1;
   crypto_stream_xor(c,m,d,n,k);
-  crypto_onetimeauth(c + 16,c + 32,d - 32,c);
-  FOR(i,16) c[i] = 0;
+  crypto_onetimeauth(c + crypto_box_BOXZEROBYTES,c + crypto_box_ZEROBYTES,
+                 d - crypto_box_ZEROBYTES,c);
+  FOR(i,crypto_box_BOXZEROBYTES) c[i] = 0;
   return 0;
 }
 
@@ -257,11 +258,12 @@ int crypto_secretbox_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k)
 {
   unsigned int i;
   u8 x[32];
-  if (d < 32) return -1;
+  if (d < crypto_box_ZEROBYTES) return -1;
   crypto_stream(x,32,n,k);
-  if (crypto_onetimeauth_verify(c + 16,c + 32,d - 32,x) != 0) return -1;
+  if (crypto_onetimeauth_verify(c + crypto_box_BOXZEROBYTES,
+                 c + crypto_box_ZEROBYTES,d - crypto_box_ZEROBYTES,x) != 0) return -1;
   crypto_stream_xor(m,c,d,n,k);
-  FOR(i,32) m[i] = 0;
+  FOR(i,crypto_box_ZEROBYTES) m[i] = 0;
   return 0;
 }
 
index c9d75fe8a117cf2cdca205501addb22cf8d3844d..b661b69c2f83c5f8c7e757c723cda4f969057d1b 100644 (file)
@@ -39,8 +39,8 @@ extern int crypto_auth_hmacsha512256_tweet_verify(const guchar *,const guchar *,
 #define crypto_box_curve25519xsalsa20poly1305_tweet_SECRETKEYBYTES 32
 #define crypto_box_curve25519xsalsa20poly1305_tweet_BEFORENMBYTES 32
 #define crypto_box_curve25519xsalsa20poly1305_tweet_NONCEBYTES 24
-#define crypto_box_curve25519xsalsa20poly1305_tweet_ZEROBYTES 32
-#define crypto_box_curve25519xsalsa20poly1305_tweet_BOXZEROBYTES 16
+#define crypto_box_curve25519xsalsa20poly1305_tweet_ZEROBYTES 16
+#define crypto_box_curve25519xsalsa20poly1305_tweet_BOXZEROBYTES 0
 extern int crypto_box_curve25519xsalsa20poly1305_tweet(guchar *,const guchar *,guint64,const guchar *,const guchar *,const guchar *);
 extern int crypto_box_curve25519xsalsa20poly1305_tweet_open(guchar *,const guchar *,guint64,const guchar *,const guchar *,const guchar *);
 extern int crypto_box_curve25519xsalsa20poly1305_tweet_keypair(guchar *,guchar *);