summaryrefslogtreecommitdiff
path: root/thirdparty/misc
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/misc')
-rw-r--r--thirdparty/misc/aes256.cpp397
-rw-r--r--thirdparty/misc/aes256.h46
-rw-r--r--thirdparty/misc/base64.c118
-rw-r--r--thirdparty/misc/base64.h18
-rw-r--r--thirdparty/misc/md5.cpp267
-rw-r--r--thirdparty/misc/md5.h61
-rw-r--r--thirdparty/misc/sha256.c245
-rw-r--r--thirdparty/misc/sha256.h50
8 files changed, 0 insertions, 1202 deletions
diff --git a/thirdparty/misc/aes256.cpp b/thirdparty/misc/aes256.cpp
deleted file mode 100644
index dc271928b4..0000000000
--- a/thirdparty/misc/aes256.cpp
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
-* Byte-oriented AES-256 implementation.
-* All lookup tables replaced with 'on the fly' calculations.
-*
-* Copyright (c) 2007-2011 Ilya O. Levin, http://www.literatecode.com
-* Other contributors: Hal Finney
-*
-* Permission to use, copy, modify, and distribute this software for any
-* purpose with or without fee is hereby granted, provided that the above
-* copyright notice and this permission notice appear in all copies.
-*
-* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-#include "aes256.h"
-
-#define FD(x) (((x) >> 1) ^ (((x) & 1) ? 0x8d : 0))
-
-#define BACK_TO_TABLES
-
-static uint8_t rj_xtime(uint8_t);
-static void aes_subBytes(uint8_t *);
-static void aes_subBytes_inv(uint8_t *);
-static void aes_addRoundKey(uint8_t *, uint8_t *);
-static void aes_addRoundKey_cpy(uint8_t *, uint8_t *, uint8_t *);
-static void aes_shiftRows(uint8_t *);
-static void aes_shiftRows_inv(uint8_t *);
-static void aes_mixColumns(uint8_t *);
-static void aes_mixColumns_inv(uint8_t *);
-static void aes_expandEncKey(uint8_t *, uint8_t *);
-static void aes_expandDecKey(uint8_t *, uint8_t *);
-#ifndef BACK_TO_TABLES
-static uint8_t gf_alog(uint8_t);
-static uint8_t gf_log(uint8_t);
-static uint8_t gf_mulinv(uint8_t);
-static uint8_t rj_sbox(uint8_t);
-static uint8_t rj_sbox_inv(uint8_t);
-#endif
-
-#ifdef BACK_TO_TABLES
-
-static const uint8_t sbox[256] = {
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
- 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
- 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
- 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
- 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
- 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
- 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
- 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
- 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
- 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
- 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
- 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
- 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
- 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
- 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
- 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
- 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-static const uint8_t sboxinv[256] = {
- 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
- 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
- 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
- 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
- 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d,
- 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
- 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2,
- 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
- 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
- 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
- 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda,
- 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
- 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a,
- 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
- 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
- 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
- 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea,
- 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
- 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85,
- 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
- 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
- 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
- 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20,
- 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
- 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31,
- 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
- 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
- 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
- 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0,
- 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
- 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26,
- 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
-};
-
-#define rj_sbox(x) sbox[(x)]
-#define rj_sbox_inv(x) sboxinv[(x)]
-
-#else /* tableless subroutines */
-
-/* -------------------------------------------------------------------------- */
-static uint8_t gf_alog(uint8_t x) // calculate anti-logarithm gen 3
-{
- uint8_t y = 1, i;
-
- for (i = 0; i < x; i++) y ^= rj_xtime(y);
-
- return y;
-} /* gf_alog */
-
-/* -------------------------------------------------------------------------- */
-static uint8_t gf_log(uint8_t x) // calculate logarithm gen 3
-{
- uint8_t y, i = 0;
-
- if (x)
- for (i = 1, y = 1; i > 0; i++ )
- {
- y ^= rj_xtime(y);
- if (y == x) break;
- }
-
- return i;
-} /* gf_log */
-
-
-/* -------------------------------------------------------------------------- */
-static uint8_t gf_mulinv(uint8_t x) // calculate multiplicative inverse
-{
- return (x) ? gf_alog(255 - gf_log(x)) : 0;
-} /* gf_mulinv */
-
-/* -------------------------------------------------------------------------- */
-static uint8_t rj_sbox(uint8_t x)
-{
- uint8_t y, sb;
-
- sb = y = gf_mulinv(x);
- y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
- y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
- y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
- y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
-
- return (sb ^ 0x63);
-} /* rj_sbox */
-
-/* -------------------------------------------------------------------------- */
-static uint8_t rj_sbox_inv(uint8_t x)
-{
- uint8_t y, sb;
-
- y = x ^ 0x63;
- sb = y = (uint8_t)(y << 1) | (y >> 7);
- y = (uint8_t)(y << 2) | (y >> 6);
- sb ^= y;
- y = (uint8_t)(y << 3) | (y >> 5);
- sb ^= y;
-
- return gf_mulinv(sb);
-} /* rj_sbox_inv */
-
-#endif
-
-/* -------------------------------------------------------------------------- */
-static uint8_t rj_xtime(uint8_t x)
-{
- uint8_t y = (uint8_t)(x << 1);
- return (x & 0x80) ? (y ^ 0x1b) : y;
-} /* rj_xtime */
-
-/* -------------------------------------------------------------------------- */
-static void aes_subBytes(uint8_t *buf)
-{
- register uint8_t i = 16;
-
- while (i--) buf[i] = rj_sbox(buf[i]);
-} /* aes_subBytes */
-
-/* -------------------------------------------------------------------------- */
-static void aes_subBytes_inv(uint8_t *buf)
-{
- register uint8_t i = 16;
-
- while (i--) buf[i] = rj_sbox_inv(buf[i]);
-} /* aes_subBytes_inv */
-
-/* -------------------------------------------------------------------------- */
-static void aes_addRoundKey(uint8_t *buf, uint8_t *key)
-{
- register uint8_t i = 16;
-
- while (i--) buf[i] ^= key[i];
-} /* aes_addRoundKey */
-
-/* -------------------------------------------------------------------------- */
-static void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk)
-{
- register uint8_t i = 16;
-
- while (i--) buf[i] ^= (cpk[i] = key[i]), cpk[16 + i] = key[16 + i];
-} /* aes_addRoundKey_cpy */
-
-
-/* -------------------------------------------------------------------------- */
-static void aes_shiftRows(uint8_t *buf)
-{
- register uint8_t i, j; /* to make it potentially parallelable :) */
-
- i = buf[1], buf[1] = buf[5], buf[5] = buf[9], buf[9] = buf[13], buf[13] = i;
- i = buf[10], buf[10] = buf[2], buf[2] = i;
- j = buf[3], buf[3] = buf[15], buf[15] = buf[11], buf[11] = buf[7], buf[7] = j;
- j = buf[14], buf[14] = buf[6], buf[6] = j;
-
-} /* aes_shiftRows */
-
-/* -------------------------------------------------------------------------- */
-static void aes_shiftRows_inv(uint8_t *buf)
-{
- register uint8_t i, j; /* same as above :) */
-
- i = buf[1], buf[1] = buf[13], buf[13] = buf[9], buf[9] = buf[5], buf[5] = i;
- i = buf[2], buf[2] = buf[10], buf[10] = i;
- j = buf[3], buf[3] = buf[7], buf[7] = buf[11], buf[11] = buf[15], buf[15] = j;
- j = buf[6], buf[6] = buf[14], buf[14] = j;
-
-} /* aes_shiftRows_inv */
-
-/* -------------------------------------------------------------------------- */
-static void aes_mixColumns(uint8_t *buf)
-{
- register uint8_t i, a, b, c, d, e;
-
- for (i = 0; i < 16; i += 4)
- {
- a = buf[i];
- b = buf[i + 1];
- c = buf[i + 2];
- d = buf[i + 3];
- e = a ^ b ^ c ^ d;
- buf[i] ^= e ^ rj_xtime(a ^ b);
- buf[i + 1] ^= e ^ rj_xtime(b ^ c);
- buf[i + 2] ^= e ^ rj_xtime(c ^ d);
- buf[i + 3] ^= e ^ rj_xtime(d ^ a);
- }
-} /* aes_mixColumns */
-
-/* -------------------------------------------------------------------------- */
-void aes_mixColumns_inv(uint8_t *buf)
-{
- register uint8_t i, a, b, c, d, e, x, y, z;
-
- for (i = 0; i < 16; i += 4)
- {
- a = buf[i];
- b = buf[i + 1];
- c = buf[i + 2];
- d = buf[i + 3];
- e = a ^ b ^ c ^ d;
- z = rj_xtime(e);
- x = e ^ rj_xtime(rj_xtime(z ^ a ^ c));
- y = e ^ rj_xtime(rj_xtime(z ^ b ^ d));
- buf[i] ^= x ^ rj_xtime(a ^ b);
- buf[i + 1] ^= y ^ rj_xtime(b ^ c);
- buf[i + 2] ^= x ^ rj_xtime(c ^ d);
- buf[i + 3] ^= y ^ rj_xtime(d ^ a);
- }
-} /* aes_mixColumns_inv */
-
-/* -------------------------------------------------------------------------- */
-static void aes_expandEncKey(uint8_t *k, uint8_t *rc)
-{
- register uint8_t i;
-
- k[0] ^= rj_sbox(k[29]) ^ (*rc);
- k[1] ^= rj_sbox(k[30]);
- k[2] ^= rj_sbox(k[31]);
- k[3] ^= rj_sbox(k[28]);
- *rc = rj_xtime( *rc);
-
- for(i = 4; i < 16; i += 4) k[i] ^= k[i - 4], k[i + 1] ^= k[i - 3],
- k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
- k[16] ^= rj_sbox(k[12]);
- k[17] ^= rj_sbox(k[13]);
- k[18] ^= rj_sbox(k[14]);
- k[19] ^= rj_sbox(k[15]);
-
- for(i = 20; i < 32; i += 4) k[i] ^= k[i - 4], k[i + 1] ^= k[i - 3],
- k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
-
-} /* aes_expandEncKey */
-
-/* -------------------------------------------------------------------------- */
-void aes_expandDecKey(uint8_t *k, uint8_t *rc)
-{
- uint8_t i;
-
- for(i = 28; i > 16; i -= 4) k[i + 0] ^= k[i - 4], k[i + 1] ^= k[i - 3],
- k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
-
- k[16] ^= rj_sbox(k[12]);
- k[17] ^= rj_sbox(k[13]);
- k[18] ^= rj_sbox(k[14]);
- k[19] ^= rj_sbox(k[15]);
-
- for(i = 12; i > 0; i -= 4) k[i + 0] ^= k[i - 4], k[i + 1] ^= k[i - 3],
- k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
-
- *rc = FD(*rc);
- k[0] ^= rj_sbox(k[29]) ^ (*rc);
- k[1] ^= rj_sbox(k[30]);
- k[2] ^= rj_sbox(k[31]);
- k[3] ^= rj_sbox(k[28]);
-} /* aes_expandDecKey */
-
-
-/* -------------------------------------------------------------------------- */
-void aes256_init(aes256_context *ctx, uint8_t *k)
-{
- uint8_t rcon = 1;
- register uint8_t i;
-
- for (i = 0; i < sizeof(ctx->key); i++) ctx->enckey[i] = ctx->deckey[i] = k[i];
- for (i = 8; --i;) aes_expandEncKey(ctx->deckey, &rcon);
-} /* aes256_init */
-
-/* -------------------------------------------------------------------------- */
-void aes256_done(aes256_context *ctx)
-{
- register uint8_t i;
-
- for (i = 0; i < sizeof(ctx->key); i++)
- ctx->key[i] = ctx->enckey[i] = ctx->deckey[i] = 0;
-} /* aes256_done */
-
-/* -------------------------------------------------------------------------- */
-void aes256_encrypt_ecb(aes256_context *ctx, uint8_t *buf)
-{
- uint8_t i, rcon;
-
- aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key);
- for(i = 1, rcon = 1; i < 14; ++i)
- {
- aes_subBytes(buf);
- aes_shiftRows(buf);
- aes_mixColumns(buf);
- if( i & 1 ) aes_addRoundKey( buf, &ctx->key[16]);
- else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key);
- }
- aes_subBytes(buf);
- aes_shiftRows(buf);
- aes_expandEncKey(ctx->key, &rcon);
- aes_addRoundKey(buf, ctx->key);
-} /* aes256_encrypt */
-
-/* -------------------------------------------------------------------------- */
-void aes256_decrypt_ecb(aes256_context *ctx, uint8_t *buf)
-{
- uint8_t i, rcon;
-
- aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key);
- aes_shiftRows_inv(buf);
- aes_subBytes_inv(buf);
-
- for (i = 14, rcon = 0x80; --i;)
- {
- if( ( i & 1 ) )
- {
- aes_expandDecKey(ctx->key, &rcon);
- aes_addRoundKey(buf, &ctx->key[16]);
- }
- else aes_addRoundKey(buf, ctx->key);
- aes_mixColumns_inv(buf);
- aes_shiftRows_inv(buf);
- aes_subBytes_inv(buf);
- }
- aes_addRoundKey( buf, ctx->key);
-} /* aes256_decrypt */
diff --git a/thirdparty/misc/aes256.h b/thirdparty/misc/aes256.h
deleted file mode 100644
index 150a0670f5..0000000000
--- a/thirdparty/misc/aes256.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Byte-oriented AES-256 implementation.
-* All lookup tables replaced with 'on the fly' calculations.
-*
-* Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
-* Other contributors: Hal Finney
-*
-* Permission to use, copy, modify, and distribute this software for any
-* purpose with or without fee is hereby granted, provided that the above
-* copyright notice and this permission notice appear in all copies.
-*
-* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-
-#ifndef AES_256_H
-#define AES_256_H
-
-#include "core/typedefs.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- typedef struct {
- uint8_t key[32];
- uint8_t enckey[32];
- uint8_t deckey[32];
- } aes256_context;
-
-
- void aes256_init(aes256_context *, uint8_t * /* key */);
- void aes256_done(aes256_context *);
- void aes256_encrypt_ecb(aes256_context *, uint8_t * /* plaintext */);
- void aes256_decrypt_ecb(aes256_context *, uint8_t * /* cipertext */);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/thirdparty/misc/base64.c b/thirdparty/misc/base64.c
deleted file mode 100644
index 0929ae5db5..0000000000
--- a/thirdparty/misc/base64.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * File: base64.c
- * Description: Simple BASE64 conversion methods
- * Author: Ari Edelkind
- * License: Public Domain
- * Website: http://episec.com/people/edelkind/c.html
- */
-
-#include <string.h>
-
-char b64string[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-long base64_encode (to, from, len)
- char *to, *from;
- unsigned int len;
-{
- char *fromp = from;
- char *top = to;
- unsigned char cbyte;
- unsigned char obyte;
- char end[3];
-
- for (; len >= 3; len -= 3) {
- cbyte = *fromp++;
- *top++ = b64string[(int)(cbyte >> 2)];
- obyte = (cbyte << 4) & 0x30; /* 0011 0000 */
-
- cbyte = *fromp++;
- obyte |= (cbyte >> 4); /* 0000 1111 */
- *top++ = b64string[(int)obyte];
- obyte = (cbyte << 2) & 0x3C; /* 0011 1100 */
-
- cbyte = *fromp++;
- obyte |= (cbyte >> 6); /* 0000 0011 */
- *top++ = b64string[(int)obyte];
- *top++ = b64string[(int)(cbyte & 0x3F)];/* 0011 1111 */
- }
-
- if (len) {
- end[0] = *fromp++;
- if (--len) end[1] = *fromp++; else end[1] = 0;
- end[2] = 0;
-
- cbyte = end[0];
- *top++ = b64string[(int)(cbyte >> 2)];
- obyte = (cbyte << 4) & 0x30; /* 0011 0000 */
-
- cbyte = end[1];
- obyte |= (cbyte >> 4);
- *top++ = b64string[(int)obyte];
- obyte = (cbyte << 2) & 0x3C; /* 0011 1100 */
-
- if (len) *top++ = b64string[(int)obyte];
- else *top++ = '=';
- *top++ = '=';
- }
- *top = 0;
- return top - to;
-}
-
-/* badchar(): check if c is decent; puts either the */
-/* location of c or null into p. */
-#define badchar(c,p) (!(p = memchr(b64string, c, 64)))
-
-long base64_decode (to, from, len)
- char *to, *from;
- unsigned int len;
-{
- char *fromp = from;
- char *top = to;
- char *p;
- unsigned char cbyte;
- unsigned char obyte;
- int padding = 0;
-
- for (; len >= 4; len -= 4) {
- if ((cbyte = *fromp++) == '=') cbyte = 0;
- else {
- if (badchar(cbyte, p)) return -1;
- cbyte = (p - b64string);
- }
- obyte = cbyte << 2; /* 1111 1100 */
-
- if ((cbyte = *fromp++) == '=') cbyte = 0;
- else {
- if (badchar(cbyte, p)) return -1;
- cbyte = p - b64string;
- }
- obyte |= cbyte >> 4; /* 0000 0011 */
- *top++ = obyte;
-
- obyte = cbyte << 4; /* 1111 0000 */
- if ((cbyte = *fromp++) == '=') { cbyte = 0; padding++; }
- else {
- padding = 0;
- if (badchar (cbyte, p)) return -1;
- cbyte = p - b64string;
- }
- obyte |= cbyte >> 2; /* 0000 1111 */
- *top++ = obyte;
-
- obyte = cbyte << 6; /* 1100 0000 */
- if ((cbyte = *fromp++) == '=') { cbyte = 0; padding++; }
- else {
- padding = 0;
- if (badchar (cbyte, p)) return -1;
- cbyte = p - b64string;
- }
- obyte |= cbyte; /* 0011 1111 */
- *top++ = obyte;
- }
-
- *top = 0;
- if (len) return -1;
- return (top - to) - padding;
-}
-
diff --git a/thirdparty/misc/base64.h b/thirdparty/misc/base64.h
deleted file mode 100644
index ffcd0af973..0000000000
--- a/thirdparty/misc/base64.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * File: base64.h
- * Description: Simple BASE64 conversion methods
- * Author: Ari Edelkind
- * License: Public Domain
- * Website: http://episec.com/people/edelkind/c.html
- */
-
-#ifndef BASE64_H
-#define BASE64_H
-
-extern "C" {
-
-long base64_encode(char *to, char *from, unsigned int len);
-long base64_decode(char *to, char *from, unsigned int len);
-};
-
-#endif /* BASE64_H */
diff --git a/thirdparty/misc/md5.cpp b/thirdparty/misc/md5.cpp
deleted file mode 100644
index 1653ab0be5..0000000000
--- a/thirdparty/misc/md5.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- **********************************************************************
- ** md5.c **
- ** RSA Data Security, Inc. MD5 Message Digest Algorithm **
- ** Created: 2/17/90 RLR **
- ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- ** **
- ** License to copy and use this software is granted provided that **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function. **
- ** **
- ** License is also granted to make and use derivative works **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all **
- ** material mentioning or referencing the derived work. **
- ** **
- ** RSA Data Security, Inc. makes no representations concerning **
- ** either the merchantability of this software or the suitability **
- ** of this software for any particular purpose. It is provided "as **
- ** is" without express or implied warranty of any kind. **
- ** **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software. **
- **********************************************************************
- */
-
-/* -- include the following line if the md5.h header file is separate -- */
-#include "md5.h"
-
-/* forward declaration */
-static void Transform (uint32_t *buf, uint32_t *in);
-
-
-static unsigned char PADDING[64] = {
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-/* F, G and H are basic MD5 functions: selection, majority, parity */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-/* ROTATE_LEFT rotates x left n bits */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
-/* Rotation is separate from addition to prevent recomputation */
-#define FF(a, b, c, d, x, s, ac) \
- {(a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) \
- {(a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) \
- {(a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) \
- {(a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-void MD5Init (MD5_CTX *mdContext)
-{
- mdContext->i[0] = mdContext->i[1] = (uint32_t)0;
-
- /* Load magic initialization constants.
- */
- mdContext->buf[0] = (uint32_t)0x67452301;
- mdContext->buf[1] = (uint32_t)0xefcdab89;
- mdContext->buf[2] = (uint32_t)0x98badcfe;
- mdContext->buf[3] = (uint32_t)0x10325476;
-}
-
-void MD5Update (MD5_CTX *mdContext,unsigned char *inBuf,unsigned int inLen) {
- uint32_t in[16];
- int mdi;
- unsigned int i, ii;
-
- /* compute number of bytes mod 64 */
- mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
- /* update number of bits */
- if ((mdContext->i[0] + ((uint32_t)inLen << 3)) < mdContext->i[0])
- mdContext->i[1]++;
- mdContext->i[0] += ((uint32_t)inLen << 3);
- mdContext->i[1] += ((uint32_t)inLen >> 29);
-
- while (inLen--) {
- /* add new character to buffer, increment mdi */
- mdContext->in[mdi++] = *inBuf++;
-
- /* transform if necessary */
- if (mdi == 0x40) {
- for (i = 0, ii = 0; i < 16; i++, ii += 4)
- in[i] = (((uint32_t)mdContext->in[ii+3]) << 24) |
- (((uint32_t)mdContext->in[ii+2]) << 16) |
- (((uint32_t)mdContext->in[ii+1]) << 8) |
- ((uint32_t)mdContext->in[ii]);
- Transform (mdContext->buf, in);
- mdi = 0;
- }
- }
-}
-
-void MD5Final (MD5_CTX *mdContext) {
- uint32_t in[16];
- int mdi;
- unsigned int i, ii;
- unsigned int padLen;
-
- /* save number of bits */
- in[14] = mdContext->i[0];
- in[15] = mdContext->i[1];
-
- /* compute number of bytes mod 64 */
- mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
- /* pad out to 56 mod 64 */
- padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
- MD5Update (mdContext, PADDING, padLen);
-
- /* append length in bits and transform */
- for (i = 0, ii = 0; i < 14; i++, ii += 4)
- in[i] = (((uint32_t)mdContext->in[ii+3]) << 24) |
- (((uint32_t)mdContext->in[ii+2]) << 16) |
- (((uint32_t)mdContext->in[ii+1]) << 8) |
- ((uint32_t)mdContext->in[ii]);
- Transform (mdContext->buf, in);
-
- /* store buffer in digest */
- for (i = 0, ii = 0; i < 4; i++, ii += 4) {
- mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
- mdContext->digest[ii+1] =
- (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
- mdContext->digest[ii+2] =
- (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
- mdContext->digest[ii+3] =
- (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
- }
-}
-
-/* Basic MD5 step. Transform buf based on in.
- */
-static void Transform (uint32_t *buf, uint32_t *in) {
- uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3];
-
- /* Round 1 */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
- FF ( a, b, c, d, in[ 0], S11, 3614090360); /* 1 */
- FF ( d, a, b, c, in[ 1], S12, 3905402710); /* 2 */
- FF ( c, d, a, b, in[ 2], S13, 606105819); /* 3 */
- FF ( b, c, d, a, in[ 3], S14, 3250441966); /* 4 */
- FF ( a, b, c, d, in[ 4], S11, 4118548399); /* 5 */
- FF ( d, a, b, c, in[ 5], S12, 1200080426); /* 6 */
- FF ( c, d, a, b, in[ 6], S13, 2821735955); /* 7 */
- FF ( b, c, d, a, in[ 7], S14, 4249261313); /* 8 */
- FF ( a, b, c, d, in[ 8], S11, 1770035416); /* 9 */
- FF ( d, a, b, c, in[ 9], S12, 2336552879); /* 10 */
- FF ( c, d, a, b, in[10], S13, 4294925233); /* 11 */
- FF ( b, c, d, a, in[11], S14, 2304563134); /* 12 */
- FF ( a, b, c, d, in[12], S11, 1804603682); /* 13 */
- FF ( d, a, b, c, in[13], S12, 4254626195); /* 14 */
- FF ( c, d, a, b, in[14], S13, 2792965006); /* 15 */
- FF ( b, c, d, a, in[15], S14, 1236535329); /* 16 */
-
- /* Round 2 */
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
- GG ( a, b, c, d, in[ 1], S21, 4129170786); /* 17 */
- GG ( d, a, b, c, in[ 6], S22, 3225465664); /* 18 */
- GG ( c, d, a, b, in[11], S23, 643717713); /* 19 */
- GG ( b, c, d, a, in[ 0], S24, 3921069994); /* 20 */
- GG ( a, b, c, d, in[ 5], S21, 3593408605); /* 21 */
- GG ( d, a, b, c, in[10], S22, 38016083); /* 22 */
- GG ( c, d, a, b, in[15], S23, 3634488961); /* 23 */
- GG ( b, c, d, a, in[ 4], S24, 3889429448); /* 24 */
- GG ( a, b, c, d, in[ 9], S21, 568446438); /* 25 */
- GG ( d, a, b, c, in[14], S22, 3275163606); /* 26 */
- GG ( c, d, a, b, in[ 3], S23, 4107603335); /* 27 */
- GG ( b, c, d, a, in[ 8], S24, 1163531501); /* 28 */
- GG ( a, b, c, d, in[13], S21, 2850285829); /* 29 */
- GG ( d, a, b, c, in[ 2], S22, 4243563512); /* 30 */
- GG ( c, d, a, b, in[ 7], S23, 1735328473); /* 31 */
- GG ( b, c, d, a, in[12], S24, 2368359562); /* 32 */
-
- /* Round 3 */
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
- HH ( a, b, c, d, in[ 5], S31, 4294588738); /* 33 */
- HH ( d, a, b, c, in[ 8], S32, 2272392833); /* 34 */
- HH ( c, d, a, b, in[11], S33, 1839030562); /* 35 */
- HH ( b, c, d, a, in[14], S34, 4259657740); /* 36 */
- HH ( a, b, c, d, in[ 1], S31, 2763975236); /* 37 */
- HH ( d, a, b, c, in[ 4], S32, 1272893353); /* 38 */
- HH ( c, d, a, b, in[ 7], S33, 4139469664); /* 39 */
- HH ( b, c, d, a, in[10], S34, 3200236656); /* 40 */
- HH ( a, b, c, d, in[13], S31, 681279174); /* 41 */
- HH ( d, a, b, c, in[ 0], S32, 3936430074); /* 42 */
- HH ( c, d, a, b, in[ 3], S33, 3572445317); /* 43 */
- HH ( b, c, d, a, in[ 6], S34, 76029189); /* 44 */
- HH ( a, b, c, d, in[ 9], S31, 3654602809); /* 45 */
- HH ( d, a, b, c, in[12], S32, 3873151461); /* 46 */
- HH ( c, d, a, b, in[15], S33, 530742520); /* 47 */
- HH ( b, c, d, a, in[ 2], S34, 3299628645); /* 48 */
-
- /* Round 4 */
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
- II ( a, b, c, d, in[ 0], S41, 4096336452); /* 49 */
- II ( d, a, b, c, in[ 7], S42, 1126891415); /* 50 */
- II ( c, d, a, b, in[14], S43, 2878612391); /* 51 */
- II ( b, c, d, a, in[ 5], S44, 4237533241); /* 52 */
- II ( a, b, c, d, in[12], S41, 1700485571); /* 53 */
- II ( d, a, b, c, in[ 3], S42, 2399980690); /* 54 */
- II ( c, d, a, b, in[10], S43, 4293915773); /* 55 */
- II ( b, c, d, a, in[ 1], S44, 2240044497); /* 56 */
- II ( a, b, c, d, in[ 8], S41, 1873313359); /* 57 */
- II ( d, a, b, c, in[15], S42, 4264355552); /* 58 */
- II ( c, d, a, b, in[ 6], S43, 2734768916); /* 59 */
- II ( b, c, d, a, in[13], S44, 1309151649); /* 60 */
- II ( a, b, c, d, in[ 4], S41, 4149444226); /* 61 */
- II ( d, a, b, c, in[11], S42, 3174756917); /* 62 */
- II ( c, d, a, b, in[ 2], S43, 718787259); /* 63 */
- II ( b, c, d, a, in[ 9], S44, 3951481745); /* 64 */
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
-
-/*
- **********************************************************************
- ** End of md5.c **
- ******************************* (cut) ********************************
- */
diff --git a/thirdparty/misc/md5.h b/thirdparty/misc/md5.h
deleted file mode 100644
index 14b3cd3ddf..0000000000
--- a/thirdparty/misc/md5.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-
-/*
- **********************************************************************
- ** md5.h -- Header file for implementation of MD5 **
- ** RSA Data Security, Inc. MD5 Message Digest Algorithm **
- ** Created: 2/17/90 RLR **
- ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
- ** Revised (for MD5): RLR 4/27/91 **
- ** -- G modified to have y&~z instead of y&z **
- ** -- FF, GG, HH modified to add in last register done **
- ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
- ** -- distinct additive constant for each step **
- ** -- round 4 added, working mod 7 **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- ** **
- ** License to copy and use this software is granted provided that **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function. **
- ** **
- ** License is also granted to make and use derivative works **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all **
- ** material mentioning or referencing the derived work. **
- ** **
- ** RSA Data Security, Inc. makes no representations concerning **
- ** either the merchantability of this software or the suitability **
- ** of this software for any particular purpose. It is provided "as **
- ** is" without express or implied warranty of any kind. **
- ** **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software. **
- **********************************************************************
- */
-
-/* NOT typedef a 32 bit type */
-
-#include "core/typedefs.h"
-
-/* Data structure for MD5 (Message Digest) computation */
-typedef struct {
- uint32_t i[2]; /* number of _bits_ handled mod 2^64 */
- uint32_t buf[4]; /* scratch buffer */
- unsigned char in[64]; /* input buffer */
- unsigned char digest[16]; /* actual digest after MD5Final call */
-} MD5_CTX;
-
-void MD5Init (MD5_CTX *mdContext);
-void MD5Update (MD5_CTX *mdContext,unsigned char *inBuf,unsigned int inLen);
-void MD5Final (MD5_CTX *mdContext);
-
-
-
-#endif // MD5_H
diff --git a/thirdparty/misc/sha256.c b/thirdparty/misc/sha256.c
deleted file mode 100644
index 68a4339af9..0000000000
--- a/thirdparty/misc/sha256.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
-* SHA-256 implementation.
-*
-* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
-*
-* Permission to use, copy, modify, and distribute this software for any
-* purpose with or without fee is hereby granted, provided that the above
-* copyright notice and this permission notice appear in all copies.
-*
-* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-#define SWAP_BYTES
-// #define USE_STD_MEMCPY
-// #define SELF_TEST
-
-#ifdef USE_STD_MEMCPY
-#include <string.h>
-#endif
-#include "sha256.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define RL(x,n) (((x) << n) | ((x) >> (32 - n)))
-#define RR(x,n) (((x) >> n) | ((x) << (32 - n)))
-
-#define S0(x) (RR((x), 2) ^ RR((x),13) ^ RR((x),22))
-#define S1(x) (RR((x), 6) ^ RR((x),11) ^ RR((x),25))
-#define G0(x) (RR((x), 7) ^ RR((x),18) ^ ((x) >> 3))
-#define G1(x) (RR((x),17) ^ RR((x),19) ^ ((x) >> 10))
-
-#ifdef SWAP_BYTES
-#define BSWP(x,y) _bswapw((uint32_t *)(x), (uint32_t)(y))
-#else
-#define BSWP(p,n)
-#endif
-#ifdef USE_STD_MEMCPY
-#define MEMCP(x,y,z) memcpy((x),(y),(z))
-#else
-#define MEMCP(x,y,z) _memcp((x),(y),(z))
-#endif
-
-#ifndef __cdecl
-#define __cdecl
-#endif
-
-static const uint32_t K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-};
-
-/* -------------------------------------------------------------------------- */
-static void _bswapw(uint32_t *p, uint32_t i)
-{
- while (i--) p[i] = (RR(p[i],24) & 0x00ff00ff) | (RR(p[i],8) & 0xff00ff00);
-
-} /* _bswapw */
-
-/* -------------------------------------------------------------------------- */
-#ifndef USE_STD_MEMCPY
-void * __cdecl _memcp (void *d, const void *s, uint32_t sz)
-{
- void *rv = d;
-
- while (sz--) *(char *)d = *(char *)s, d = (char *)d + 1, s = (char *)s + 1;
-
- return(rv);
-} /* _memcp */
-#endif
-
-/* -------------------------------------------------------------------------- */
-static void _rtrf(uint32_t *b, uint32_t *p, uint32_t i, uint32_t j)
-{
- #define B(x, y) b[(x-y) & 7]
- #define P(x, y) p[(x+y) & 15]
-
- B(7,i) += (j ? (p[i & 15] += G1(P(i,14)) + P(i,9) + G0(P(i,1))) : p[i & 15])
- + K[i+j] + S1(B(4,i))
- + (B(6,i) ^ (B(4,i) & (B(5,i) ^ B(6,i))));
- B(3,i) += B(7,i);
- B(7,i) += S0(B(0,i)) + ( (B(0,i) & B(1,i)) | (B(2,i) & (B(0,i) ^ B(1,i))) );
-
- #undef P
- #undef B
-} /* _rtrf */
-
-/* -------------------------------------------------------------------------- */
-static void _hash(sha256_context *ctx)
-{
- uint32_t b[8], *p, j;
-
- b[0] = ctx->hash[0]; b[1] = ctx->hash[1]; b[2] = ctx->hash[2];
- b[3] = ctx->hash[3]; b[4] = ctx->hash[4]; b[5] = ctx->hash[5];
- b[6] = ctx->hash[6]; b[7] = ctx->hash[7];
-
- for (p = ctx->buf, j = 0; j < 64; j += 16)
- _rtrf(b, p, 0, j), _rtrf(b, p, 1, j), _rtrf(b, p, 2, j),
- _rtrf(b, p, 3, j), _rtrf(b, p, 4, j), _rtrf(b, p, 5, j),
- _rtrf(b, p, 6, j), _rtrf(b, p, 7, j), _rtrf(b, p, 8, j),
- _rtrf(b, p, 9, j), _rtrf(b, p, 10, j), _rtrf(b, p, 11, j),
- _rtrf(b, p, 12, j), _rtrf(b, p, 13, j), _rtrf(b, p, 14, j),
- _rtrf(b, p, 15, j);
-
- ctx->hash[0] += b[0]; ctx->hash[1] += b[1]; ctx->hash[2] += b[2];
- ctx->hash[3] += b[3]; ctx->hash[4] += b[4]; ctx->hash[5] += b[5];
- ctx->hash[6] += b[6]; ctx->hash[7] += b[7];
-
-} /* _hash */
-
-/* -------------------------------------------------------------------------- */
-void sha256_init(sha256_context ctx[1])
-{
- ctx->len[0] = ctx->len[1] = 0;
- ctx->hash[0] = 0x6a09e667; ctx->hash[1] = 0xbb67ae85;
- ctx->hash[2] = 0x3c6ef372; ctx->hash[3] = 0xa54ff53a;
- ctx->hash[4] = 0x510e527f; ctx->hash[5] = 0x9b05688c;
- ctx->hash[6] = 0x1f83d9ab; ctx->hash[7] = 0x5be0cd19;
-
-} /* sha256_init */
-
-/* -------------------------------------------------------------------------- */
-void sha256_hash(sha256_context *ctx, uint8_t *dat, uint32_t sz)
-{
- register uint32_t i = ctx->len[0] & 63, l, j;
-
- if ((ctx->len[0] += sz) < sz) ++(ctx->len[1]);
-
- for (j = 0, l = 64-i; sz >= l; j += l, sz -= l, l = 64, i = 0)
- {
- MEMCP(&ctx->buf[i], &dat[j], l);
- BSWP(ctx->buf, 16 );
- _hash(ctx);
- }
- MEMCP(&ctx->buf[i], &dat[j], sz);
-
-} /* _hash */
-
-/* -------------------------------------------------------------------------- */
-void sha256_done(sha256_context *ctx, uint8_t *buf)
-{
- uint32_t i = (uint32_t)(ctx->len[0] & 63), j = ((~i) & 3) << 3;
-
- BSWP(ctx->buf, (i + 3) >> 2);
-
- ctx->buf[i >> 2] &= 0xffffff80 << j; /* add padding */
- ctx->buf[i >> 2] |= 0x00000080 << j;
-
- if (i < 56) i = (i >> 2) + 1;
- else ctx->buf[15] ^= (i < 60) ? ctx->buf[15] : 0, _hash(ctx), i = 0;
-
- while (i < 14) ctx->buf[i++] = 0;
-
- ctx->buf[14] = (ctx->len[1] << 3)|(ctx->len[0] >> 29); /* add length */
- ctx->buf[15] = ctx->len[0] << 3;
-
- _hash(ctx);
-
- for (i = 0; i < 32; i++)
- ctx->buf[i % 16] = 0, /* may remove this line in case of a DIY cleanup */
- buf[i] = (uint8_t)(ctx->hash[i >> 2] >> ((~i & 3) << 3));
-
-} /* sha256_done */
-
-
-#ifdef SELF_TEST
-#pragma warning (push, 0)
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#pragma warning(pop)
-
-char *buf[] = {
- "",
- "e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855",
-
- "abc",
- "ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad",
-
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1",
-
- "The quick brown fox jumps over the lazy dog",
- "d7a8fbb3 07d78094 69ca9abc b0082e4f 8d5651e4 6d3cdb76 2d02d0bf 37c9e592",
-
- "The quick brown fox jumps over the lazy cog", /* avalanche effect test */
- "e4c4d8f3 bf76b692 de791a17 3e053211 50f7a345 b46484fe 427f6acc 7ecc81be",
-
- "bhn5bjmoniertqea40wro2upyflkydsibsk8ylkmgbvwi420t44cq034eou1szc1k0mk46oeb7ktzmlxqkbte2sy",
- "9085df2f 02e0cc45 5928d0f5 1b27b4bf 1d9cd260 a66ed1fd a11b0a3f f5756d99"
-};
-
-int main(int argc, char *argv[])
-{
- sha256_context ctx;
- uint8_t hv[32];
- uint32_t i, j;
-
- for (j = 0; j < (sizeof(buf)/sizeof(buf[0])); j += 2)
- {
- sha256_init(&ctx);
- sha256_hash(&ctx, (uint8_t *)buf[j], (uint32_t)strlen(buf[j]));
- sha256_done(&ctx, hv);
- printf("input = %s\ndigest: %s\nresult: ", buf[j], buf[j+1]);
- for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":"");
- printf("\n\n");
- }
-
- for (j = 1; j < (uint32_t)argc; j++)
- {
- printf("argv[%d]: %s\nresult: ", (int)j, argv[j]);
- sha256_init(&ctx);
- sha256_hash(&ctx, (uint8_t *)argv[j], (uint32_t)strlen(argv[j]));
- sha256_done(&ctx, hv);
- for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":"");
- printf("\n\n");
- }
-
- return 0;
-} /* main */
-#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/thirdparty/misc/sha256.h b/thirdparty/misc/sha256.h
deleted file mode 100644
index e19e56b4cc..0000000000
--- a/thirdparty/misc/sha256.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* SHA-256 implementation.
-*
-* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
-*
-* Permission to use, copy, modify, and distribute this software for any
-* purpose with or without fee is hereby granted, provided that the above
-* copyright notice and this permission notice appear in all copies.
-*
-* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-#ifdef _MSC_VER
-#ifndef uint8_t
-typedef unsigned __int8 uint8_t;
-#endif
-#ifndef uint32_t
-typedef unsigned __int32 uint32_t;
-#endif
-#ifndef uint64_t
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#endif
-#else
-#include <stdint.h>
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef struct {
- uint32_t buf[16];
- uint32_t hash[8];
- uint32_t len[2];
- } sha256_context;
-
- void sha256_init(sha256_context *);
- void sha256_hash(sha256_context *, uint8_t * /* data */, uint32_t /* len */);
- void sha256_done(sha256_context *, uint8_t * /* hash */);
-
-#ifdef __cplusplus
-}
-#endif