]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Delete nettle_armor abstraction. delete-nettle_armor
authorNiels Möller <nisse@lysator.liu.se>
Thu, 16 Oct 2025 06:02:13 +0000 (08:02 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 16 Oct 2025 06:02:13 +0000 (08:02 +0200)
14 files changed:
ChangeLog
Makefile.in
base16-meta.c [deleted file]
base64-meta.c [deleted file]
base64url-meta.c [deleted file]
nettle-meta-armors.c [deleted file]
nettle-meta.h
nettle-types.h
testsuite/Makefile.in
testsuite/base16-test.c
testsuite/base64-test.c
testsuite/meta-armor-test.c [deleted file]
testsuite/testutils.c
testsuite/testutils.h

index 5e205d86ae34c5afd81a9539562f68a3a40ae62a..5ad4afa4dc93326de057bf8e21e517372023c5ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2025-10-16  Niels Möller  <nisse@lysator.liu.se>
+
+       Delete the undocumented nettle_armor abstraction.
+       * nettle-types.h (nettle_armor_length_func)
+       (nettle_armor_init_func, nettle_armor_encode_update_func)
+       (nettle_armor_encode_final_func, nettle_armor_decode_update_func)
+       (nettle_armor_decode_final_func): Deleted typedefs.
+       * nettle-meta.h (struct nettle_armor): Deleted struct.
+       (_NETTLE_ARMOR, _NETTLE_ARMOR_0): Deleted macros.
+       (nettle_get_armors, nettle_armors, nettle_base64)
+       (nettle_base64url, nettle_base16): Deleted declarations.
+       * base16-meta.c: Deleted file.
+       * base64-meta.c: Deleted file.
+       * base64url-meta.c: Deleted file.
+       * nettle-meta-armors.c: Deleted file.
+       * Makefile.in (nettle_SOURCES): Drop deleted files.
+
+       * testsuite/base16-test.c (test_base16): New more concrete test function.
+       (test_main): Updated to use test_base16 rather than test_armor.
+       * testsuite/base64-test.c (test_base64): New more concretetest
+       function, parameterized only by init functions to use.
+       (test_main): Updated to use test_base64 rather than test_armor.
+       * testsuite/testutils.c (test_armor): Deleted function.
+       * testsuite/meta-armor-test.c: Deleted file.
+       * testsuite/Makefile.in (TS_NETTLE_SOURCES): Drop meta-armor-test.c.
+
 2025-10-13  Niels Möller  <nisse@lysator.liu.se>
 
        * tools/input.h (struct sexp_input): Replace use of struct
index 89de5621a149935076108c5cc2b036fb5d36c35b..c08e589a8d03f9f4d4a5ce0c1e0e7b1c461235e5 100644 (file)
@@ -94,9 +94,9 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt-table.c \
                 arctwo.c arctwo-meta.c blowfish.c blowfish-bcrypt.c \
                 balloon.c balloon-sha1.c balloon-sha256.c \
                 balloon-sha384.c balloon-sha512.c \
-                base16-encode.c base16-decode.c base16-meta.c \
-                base64-encode.c base64-decode.c base64-meta.c \
-                base64url-encode.c base64url-decode.c base64url-meta.c \
+                base16-encode.c base16-decode.c \
+                base64-encode.c base64-decode.c \
+                base64url-encode.c base64url-decode.c \
                 buffer.c buffer-init.c \
                 camellia-crypt-internal.c camellia-table.c \
                 camellia-absorb.c camellia-invert-key.c \
@@ -142,7 +142,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt-table.c \
                 md5.c md5-meta.c \
                 memeql-sec.c memxor.c memxor3.c \
                 nettle-lookup-hash.c \
-                nettle-meta-aeads.c nettle-meta-armors.c \
+                nettle-meta-aeads.c \
                 nettle-meta-ciphers.c nettle-meta-hashes.c nettle-meta-macs.c \
                 ocb.c ocb-aes128.c \
                 pbkdf2.c pbkdf2-hmac-gosthash94.c pbkdf2-hmac-sha1.c \
diff --git a/base16-meta.c b/base16-meta.c
deleted file mode 100644 (file)
index a7789c5..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* base16-meta.c
-
-   Copyright (C) 2002 Niels Möller
-
-   This file is part of GNU Nettle.
-
-   GNU Nettle is free software: you can redistribute it and/or
-   modify it under the terms of either:
-
-     * the GNU Lesser General Public License as published by the Free
-       Software Foundation; either version 3 of the License, or (at your
-       option) any later version.
-
-   or
-
-     * the GNU General Public License as published by the Free
-       Software Foundation; either version 2 of the License, or (at your
-       option) any later version.
-
-   or both in parallel, as here.
-
-   GNU Nettle is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received copies of the GNU General Public License and
-   the GNU Lesser General Public License along with this program.  If
-   not, see http://www.gnu.org/licenses/.
-*/
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "nettle-meta.h"
-
-#include "base16.h"
-
-/* Same as the macros with the same name */
-static nettle_armor_length_func base16_encode_length;
-static size_t
-base16_encode_length(size_t length)
-{
-  return BASE16_ENCODE_LENGTH(length);
-}
-
-static nettle_armor_length_func base16_decode_length;
-static size_t
-base16_decode_length(size_t length)
-{
-  return BASE16_DECODE_LENGTH(length);
-}
-
-static nettle_armor_init_func base16_encode_init;
-static void
-base16_encode_init(void *ctx UNUSED)
-{ }
-
-static nettle_armor_encode_update_func base16_encode_update_wrapper;
-static size_t
-base16_encode_update_wrapper(void *ctx UNUSED, char *dst,
-                            size_t length, const uint8_t *src)
-{
-  base16_encode_update(dst, length, src);
-  return BASE16_ENCODE_LENGTH(length);
-}
-
-#undef base16_encode_update
-#define base16_encode_update base16_encode_update_wrapper
-
-static nettle_armor_encode_final_func base16_encode_final;
-static size_t
-base16_encode_final(void *ctx UNUSED, char *dst UNUSED)
-{
-  return 0;
-}
-
-
-#define BASE16_ENCODE_FINAL_LENGTH 0
-
-const struct nettle_armor nettle_base16
-= _NETTLE_ARMOR_0(base16, BASE16);
diff --git a/base64-meta.c b/base64-meta.c
deleted file mode 100644 (file)
index b46e8ab..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* base64-meta.c
-
-   Copyright (C) 2002 Dan Egnor, Niels Möller
-
-   This file is part of GNU Nettle.
-
-   GNU Nettle is free software: you can redistribute it and/or
-   modify it under the terms of either:
-
-     * the GNU Lesser General Public License as published by the Free
-       Software Foundation; either version 3 of the License, or (at your
-       option) any later version.
-
-   or
-
-     * the GNU General Public License as published by the Free
-       Software Foundation; either version 2 of the License, or (at your
-       option) any later version.
-
-   or both in parallel, as here.
-
-   GNU Nettle is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received copies of the GNU General Public License and
-   the GNU Lesser General Public License along with this program.  If
-   not, see http://www.gnu.org/licenses/.
-*/
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "nettle-meta.h"
-
-#include "base64.h"
-
-/* Same as the macros with the same name */
-static nettle_armor_length_func base64_encode_length;
-static size_t
-base64_encode_length(size_t length)
-{
-  return BASE64_ENCODE_LENGTH(length);
-}
-
-static nettle_armor_length_func base64_decode_length;
-static size_t
-base64_decode_length(size_t length)
-{
-  return BASE64_DECODE_LENGTH(length);
-}
-
-const struct nettle_armor nettle_base64
-= _NETTLE_ARMOR(base64, BASE64);
diff --git a/base64url-meta.c b/base64url-meta.c
deleted file mode 100644 (file)
index af4afc9..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* base64url-meta.c
-
-   Copyright (C) 2015 Niels Möller
-
-   This file is part of GNU Nettle.
-
-   GNU Nettle is free software: you can redistribute it and/or
-   modify it under the terms of either:
-
-     * the GNU Lesser General Public License as published by the Free
-       Software Foundation; either version 3 of the License, or (at your
-       option) any later version.
-
-   or
-
-     * the GNU General Public License as published by the Free
-       Software Foundation; either version 2 of the License, or (at your
-       option) any later version.
-
-   or both in parallel, as here.
-
-   GNU Nettle is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received copies of the GNU General Public License and
-   the GNU Lesser General Public License along with this program.  If
-   not, see http://www.gnu.org/licenses/.
-*/
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "nettle-meta.h"
-
-#include "base64.h"
-
-/* Same as the macros with the same name */
-static nettle_armor_length_func base64url_encode_length;
-static size_t
-base64url_encode_length(size_t length)
-{
-  return BASE64_ENCODE_LENGTH(length);
-}
-
-static nettle_armor_length_func base64url_decode_length;
-static size_t
-base64url_decode_length(size_t length)
-{
-  return BASE64_DECODE_LENGTH(length);
-}
-
-#define base64url_encode_ctx base64_encode_ctx
-#define base64url_encode_update base64_encode_update
-#define base64url_encode_final base64_encode_final
-#define base64url_decode_ctx base64_decode_ctx
-#define base64url_decode_update base64_decode_update
-#define base64url_decode_final base64_decode_final
-
-const struct nettle_armor nettle_base64url
-= _NETTLE_ARMOR(base64url, BASE64);
diff --git a/nettle-meta-armors.c b/nettle-meta-armors.c
deleted file mode 100644 (file)
index 17f87fc..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* nettle-meta-armors.c
-
-   Copyright (C) 2011 Daniel Kahn Gillmor
-
-   This file is part of GNU Nettle.
-
-   GNU Nettle is free software: you can redistribute it and/or
-   modify it under the terms of either:
-
-     * the GNU Lesser General Public License as published by the Free
-       Software Foundation; either version 3 of the License, or (at your
-       option) any later version.
-
-   or
-
-     * the GNU General Public License as published by the Free
-       Software Foundation; either version 2 of the License, or (at your
-       option) any later version.
-
-   or both in parallel, as here.
-
-   GNU Nettle is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received copies of the GNU General Public License and
-   the GNU Lesser General Public License along with this program.  If
-   not, see http://www.gnu.org/licenses/.
-*/
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stddef.h>
-#include "nettle-meta.h"
-
-const struct nettle_armor * const _nettle_armors[] = {
-  &nettle_base64,
-  &nettle_base64url,
-  &nettle_base16,
-  NULL
-};
-
-const struct nettle_armor * const *
-nettle_get_armors (void)
-{
-  return _nettle_armors;
-}
index f0d4b1e29abc44d810765c42d11805e7f527c964..b9611706314892594fa95c910de74471b9cc100a 100644 (file)
@@ -184,7 +184,6 @@ struct nettle_aead
   nettle_hash_update_func *update;
   nettle_crypt_func *encrypt;
   nettle_crypt_func *decrypt;
-  /* FIXME: Drop length argument? */
   nettle_hash_digest_func *digest;
 };
 
@@ -204,65 +203,6 @@ extern const struct nettle_aead nettle_gcm_sm4;
 extern const struct nettle_aead nettle_eax_aes128;
 extern const struct nettle_aead nettle_chacha_poly1305;
 
-struct nettle_armor
-{
-  const char *name;
-  unsigned encode_context_size;
-  unsigned decode_context_size;
-
-  unsigned encode_final_length;
-
-  nettle_armor_init_func *encode_init;
-  nettle_armor_length_func *encode_length;
-  nettle_armor_encode_update_func *encode_update;
-  nettle_armor_encode_final_func *encode_final;
-  
-  nettle_armor_init_func *decode_init;
-  nettle_armor_length_func *decode_length;
-  nettle_armor_decode_update_func *decode_update;
-  nettle_armor_decode_final_func *decode_final;
-};
-
-#define _NETTLE_ARMOR(name, NAME) {                            \
-  #name,                                                       \
-  sizeof(struct name##_encode_ctx),                            \
-  sizeof(struct name##_decode_ctx),                            \
-  NAME##_ENCODE_FINAL_LENGTH,                                  \
-  (nettle_armor_init_func *) name##_encode_init,               \
-  (nettle_armor_length_func *) name##_encode_length,           \
-  (nettle_armor_encode_update_func *) name##_encode_update,    \
-  (nettle_armor_encode_final_func *) name##_encode_final,      \
-  (nettle_armor_init_func *) name##_decode_init,               \
-  (nettle_armor_length_func *) name##_decode_length,           \
-  (nettle_armor_decode_update_func *) name##_decode_update,    \
-  (nettle_armor_decode_final_func *) name##_decode_final,      \
-}
-
-#define _NETTLE_ARMOR_0(name, NAME) {                          \
-  #name,                                                       \
-  0,                                                           \
-  sizeof(struct name##_decode_ctx),                            \
-  NAME##_ENCODE_FINAL_LENGTH,                                  \
-  (nettle_armor_init_func *) name##_encode_init,               \
-  (nettle_armor_length_func *) name##_encode_length,           \
-  (nettle_armor_encode_update_func *) name##_encode_update,    \
-  (nettle_armor_encode_final_func *) name##_encode_final,      \
-  (nettle_armor_init_func *) name##_decode_init,               \
-  (nettle_armor_length_func *) name##_decode_length,           \
-  (nettle_armor_decode_update_func *) name##_decode_update,    \
-  (nettle_armor_decode_final_func *) name##_decode_final,      \
-}
-
-/* null-terminated list of armor schemes implemented by this version of nettle */
-const struct nettle_armor * const * _NETTLE_ATTRIBUTE_PURE
-nettle_get_armors (void);
-
-#define nettle_armors (nettle_get_armors())
-
-extern const struct nettle_armor nettle_base64;
-extern const struct nettle_armor nettle_base64url;
-extern const struct nettle_armor nettle_base16;
-
 #define _NETTLE_HMAC(name, HASH) {             \
   #name,                                       \
   sizeof(struct name##_ctx),                   \
index 3069c377182920ad2ec8b746a8df0614e7f3833b..b4f1c1a0cef5e2929618a8eaad857dfb94ff16c7 100644 (file)
@@ -112,26 +112,6 @@ typedef void nettle_hash_update_func(void *ctx,
                                     const uint8_t *src);
 typedef void nettle_hash_digest_func(void *ctx, uint8_t *dst);
 
-/* ASCII armor codecs. NOTE: Experimental and subject to change. */
-
-typedef size_t nettle_armor_length_func(size_t length);
-typedef void nettle_armor_init_func(void *ctx);
-
-typedef size_t nettle_armor_encode_update_func(void *ctx,
-                                              char *dst,
-                                              size_t src_length,
-                                              const uint8_t *src);
-
-typedef size_t nettle_armor_encode_final_func(void *ctx, char *dst);
-
-typedef int nettle_armor_decode_update_func(void *ctx,
-                                           size_t *dst_length,
-                                           uint8_t *dst,
-                                           size_t src_length,
-                                           const char *src);
-
-typedef int nettle_armor_decode_final_func(void *ctx);
-
 #ifdef __cplusplus
 }
 #endif
index 9a1629a279076aabf00ce58943677c07cf9e8e0c..b2f0518cf1a111266b5e511ef8331b760c088a67 100644 (file)
@@ -33,7 +33,7 @@ TS_NETTLE_SOURCES = aes-test.c aes-keywrap-test.c arcfour-test.c arctwo-test.c \
                    poly1305-test.c chacha-poly1305-test.c \
                    hmac-test.c umac-test.c \
                    meta-hash-test.c meta-cipher-test.c\
-                   meta-aead-test.c meta-armor-test.c meta-mac-test.c \
+                   meta-aead-test.c meta-mac-test.c \
                    buffer-test.c yarrow-test.c xts-test.c pbkdf2-test.c \
                    x86-ibt-test.c drbg-ctr-aes256-test.c \
                    slh-dsa-test.c
index 820915b70212d7d7973afb8f8d340c40f9f81999..8318770dd064f794473a5947039ec40c75e7623f 100644 (file)
@@ -1,6 +1,41 @@
 #include "testutils.h"
 #include "base16.h"
 
+static void
+test_base16 (size_t data_length, const uint8_t *data,
+            const char *ascii)
+{
+  size_t ascii_length = strlen(ascii);
+  char *buffer = xalloc(1 + ascii_length);
+  uint8_t *check = xalloc(1 + BASE16_DECODE_LENGTH (ascii_length));
+  struct base16_decode_ctx decode;
+  size_t done;
+
+  ASSERT(ascii_length <= BASE16_ENCODE_LENGTH (data_length));
+  ASSERT(data_length <= BASE16_DECODE_LENGTH (ascii_length));
+
+  memset(buffer, 0x33, 1 + ascii_length);
+  memset(check, 0x55, 1 + data_length);
+
+  base16_encode_update (buffer, data_length, data);
+
+  ASSERT (MEMEQ(ascii_length, buffer, ascii));
+  ASSERT (0x33 == buffer[ascii_length]);
+
+  base16_decode_init (&decode);
+  done = BASE16_DECODE_LENGTH (ascii_length);
+
+  ASSERT (base16_decode_update(&decode, &done, check, ascii_length, buffer));
+  ASSERT (done == data_length);
+  ASSERT (base16_decode_final (&decode));
+
+  ASSERT (MEMEQ(data_length, check, data));
+  ASSERT (0x55 == check[data_length]);
+
+  free(buffer);
+  free(check);
+}
+
 void
 test_main(void)
 {
@@ -13,13 +48,12 @@ test_main(void)
   ASSERT(BASE16_DECODE_LENGTH(2) == 1);
   ASSERT(BASE16_DECODE_LENGTH(3) == 2);
   ASSERT(BASE16_DECODE_LENGTH(4) == 2);
-  
-  test_armor(&nettle_base16, LDATA(""), "");
-  test_armor(&nettle_base16, LDATA("H"), "48");
-  test_armor(&nettle_base16, LDATA("He"), "4865");
-  test_armor(&nettle_base16, LDATA("Hel"), "48656c");
-  test_armor(&nettle_base16, LDATA("Hell"), "48656c6c");
-  test_armor(&nettle_base16, LDATA("Hello"), "48656c6c6f");
-  test_armor(&nettle_base16, LDATA("Hello\0"), "48656c6c6f00");
+
+  test_base16 (LDATA(""), "");
+  test_base16 (LDATA("H"), "48");
+  test_base16 (LDATA("He"), "4865");
+  test_base16 (LDATA("Hel"), "48656c");
+  test_base16 (LDATA("Hell"), "48656c6c");
+  test_base16 (LDATA("Hello"), "48656c6c6f");
+  test_base16 (LDATA("Hello\0"), "48656c6c6f00");
 }
-  
index cc45c471459ceda266938ecddc901ef36153bb7d..f021e357d62561c53795b87d3be09e836ce9a959 100644 (file)
@@ -2,6 +2,62 @@
 #include "base64.h"
 #include "knuth-lfib.h"
 
+struct base64_variant
+{
+  void (*encode_init)(struct base64_encode_ctx *ctx);
+  void (*decode_init)(struct base64_decode_ctx *ctx);
+};
+
+static const struct base64_variant base64std = {
+  base64_encode_init, base64_decode_init,
+};
+static const struct base64_variant base64url = {
+  base64url_encode_init, base64url_decode_init,
+};
+
+static void
+test_base64 (const struct base64_variant *variant,
+            size_t data_length,
+            const uint8_t *data,
+            const char *ascii)
+{
+  size_t ascii_length = strlen (ascii);
+  char *buffer = xalloc (1 + ascii_length);
+  uint8_t *check = xalloc (1 + BASE64_DECODE_LENGTH (ascii_length));
+  struct base64_encode_ctx encode;
+  struct base64_decode_ctx decode;
+  size_t done;
+
+  ASSERT (ascii_length
+         <= (BASE64_ENCODE_LENGTH (data_length) + BASE64_ENCODE_FINAL_LENGTH));
+  ASSERT (data_length <= BASE64_DECODE_LENGTH (ascii_length));
+
+  memset(buffer, 0x33, 1 + ascii_length);
+  memset(check, 0x55, 1 + data_length);
+
+  variant->encode_init(&encode);
+
+  done = base64_encode_update (&encode, buffer, data_length, data);
+  done += base64_encode_final (&encode, buffer + done);
+  ASSERT (done == ascii_length);
+
+  ASSERT (MEMEQ(ascii_length, buffer, ascii));
+  ASSERT (0x33 == buffer[ascii_length]);
+
+  variant->decode_init (&decode);
+  done = BASE64_DECODE_LENGTH (ascii_length);
+
+  ASSERT (base64_decode_update(&decode, &done, check, ascii_length, buffer));
+  ASSERT (done == data_length);
+  ASSERT (base64_decode_final(&decode));
+
+  ASSERT (MEMEQ(data_length, check, data));
+  ASSERT (0x55 == check[data_length]);
+
+  free(buffer);
+  free(check);
+}
+
 static void
 test_fuzz_once(struct base64_encode_ctx *encode,
               struct base64_decode_ctx *decode,
@@ -98,25 +154,25 @@ test_main(void)
   ASSERT(BASE64_DECODE_LENGTH(3) == 3); /* At most 24 bits */
   ASSERT(BASE64_DECODE_LENGTH(4) == 3); /* At most 30 bits */
   
-  test_armor(&nettle_base64, LDATA(""), "");
-  test_armor(&nettle_base64, LDATA("H"), "SA==");
-  test_armor(&nettle_base64, LDATA("He"), "SGU=");
-  test_armor(&nettle_base64, LDATA("Hel"), "SGVs");
-  test_armor(&nettle_base64, LDATA("Hell"), "SGVsbA==");
-  test_armor(&nettle_base64, LDATA("Hello"), "SGVsbG8=");
-  test_armor(&nettle_base64, LDATA("Hello\0"), "SGVsbG8A");
-  test_armor(&nettle_base64, LDATA("Hello?>>>"), "SGVsbG8/Pj4+");
-  test_armor(&nettle_base64, LDATA("\xff\xff\xff\xff"), "/////w==");
-
-  test_armor(&nettle_base64url, LDATA(""), "");
-  test_armor(&nettle_base64url, LDATA("H"), "SA==");
-  test_armor(&nettle_base64url, LDATA("He"), "SGU=");
-  test_armor(&nettle_base64url, LDATA("Hel"), "SGVs");
-  test_armor(&nettle_base64url, LDATA("Hell"), "SGVsbA==");
-  test_armor(&nettle_base64url, LDATA("Hello"), "SGVsbG8=");
-  test_armor(&nettle_base64url, LDATA("Hello\0"), "SGVsbG8A");
-  test_armor(&nettle_base64url, LDATA("Hello?>>>"), "SGVsbG8_Pj4-");
-  test_armor(&nettle_base64url, LDATA("\xff\xff\xff\xff"), "_____w==");
+  test_base64(&base64std, LDATA(""), "");
+  test_base64(&base64std, LDATA("H"), "SA==");
+  test_base64(&base64std, LDATA("He"), "SGU=");
+  test_base64(&base64std, LDATA("Hel"), "SGVs");
+  test_base64(&base64std, LDATA("Hell"), "SGVsbA==");
+  test_base64(&base64std, LDATA("Hello"), "SGVsbG8=");
+  test_base64(&base64std, LDATA("Hello\0"), "SGVsbG8A");
+  test_base64(&base64std, LDATA("Hello?>>>"), "SGVsbG8/Pj4+");
+  test_base64(&base64std, LDATA("\xff\xff\xff\xff"), "/////w==");
+
+  test_base64(&base64url, LDATA(""), "");
+  test_base64(&base64url, LDATA("H"), "SA==");
+  test_base64(&base64url, LDATA("He"), "SGU=");
+  test_base64(&base64url, LDATA("Hel"), "SGVs");
+  test_base64(&base64url, LDATA("Hell"), "SGVsbA==");
+  test_base64(&base64url, LDATA("Hello"), "SGVsbG8=");
+  test_base64(&base64url, LDATA("Hello\0"), "SGVsbG8A");
+  test_base64(&base64url, LDATA("Hello?>>>"), "SGVsbG8_Pj4-");
+  test_base64(&base64url, LDATA("\xff\xff\xff\xff"), "_____w==");
 
   {
     /* Test overlapping areas */
diff --git a/testsuite/meta-armor-test.c b/testsuite/meta-armor-test.c
deleted file mode 100644 (file)
index 406c8d0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "testutils.h"
-#include "nettle-meta.h"
-
-const char* armors[] = {
-  "base16",
-  "base64",
-  "base64url",
-};
-
-void
-test_main(void)
-{
-  int i,j;
-  int count = sizeof(armors)/sizeof(*armors);
-  for (i = 0; i < count; i++) {
-    for (j = 0; NULL != nettle_armors[j]; j++) {
-      if (0 == strcmp(armors[i], nettle_armors[j]->name))
-        break;
-    }
-    ASSERT(NULL != nettle_armors[j]); /* make sure we found a matching armor */
-  }
-  j = 0;
-  while (NULL != nettle_armors[j])
-    j++;
-  ASSERT(j == count); /* we are not missing testing any armors */
-}
-  
index 613bffd1c6737277b9cca01f9b965d1b14b92a15..75b4eaecc4f8955e4e5c7cfd50961f88ad5f433d 100644 (file)
@@ -1366,51 +1366,6 @@ test_mac(const struct nettle_mac *mac,
   free (hash);
 }
 
-void
-test_armor(const struct nettle_armor *armor,
-           size_t data_length,
-           const uint8_t *data,
-           const char *ascii)
-{
-  size_t ascii_length = strlen(ascii);
-  char *buffer = xalloc(1 + ascii_length);
-  uint8_t *check = xalloc(1 + armor->decode_length(ascii_length));
-  void *encode = xalloc(armor->encode_context_size);
-  void *decode = xalloc(armor->decode_context_size);
-  size_t done;
-
-  ASSERT(ascii_length
-        <= (armor->encode_length(data_length) + armor->encode_final_length));
-  ASSERT(data_length <= armor->decode_length(ascii_length));
-  
-  memset(buffer, 0x33, 1 + ascii_length);
-  memset(check, 0x55, 1 + data_length);
-
-  armor->encode_init(encode);
-  
-  done = armor->encode_update(encode, buffer, data_length, data);
-  done += armor->encode_final(encode, buffer + done);
-  ASSERT(done == ascii_length);
-
-  ASSERT (MEMEQ(ascii_length, buffer, ascii));
-  ASSERT (0x33 == buffer[strlen(ascii)]);
-
-  armor->decode_init(decode);
-  done = armor->decode_length(ascii_length);
-
-  ASSERT(armor->decode_update(decode, &done, check, ascii_length, buffer));
-  ASSERT(done == data_length);
-  ASSERT(armor->decode_final(decode));
-  
-  ASSERT (MEMEQ(data_length, check, data));
-  ASSERT (0x55 == check[data_length]);
-
-  free(buffer);
-  free(check);
-  free(encode);
-  free(decode);
-}
-
 #if WITH_HOGWEED
 
 void
index 34090aa723abda03d2d62dc394057b0b6503afd5..264811c7fdf5d58f28fc62c198fd07356dc85525 100644 (file)
@@ -202,12 +202,6 @@ test_mac(const struct nettle_mac *mac,
         const struct tstring *msg,
         const struct tstring *digest);
 
-void
-test_armor(const struct nettle_armor *armor,
-           size_t data_length,
-           const uint8_t *data,
-           const char *ascii);
-
 #if WITH_HOGWEED
 
 #if NETTLE_USE_MINI_GMP