summaryrefslogtreecommitdiffstats
path: root/cryptopp562/rc5.cpp
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-10-24 06:44:24 -0400
committerMalfurious <m@lfurio.us>2024-10-24 06:44:24 -0400
commit512aa4c77b3dc0d72db713a9215ff65a98a99ec3 (patch)
tree6db82e0109dc987b5b021f81d4e8a0926eb75ff7 /cryptopp562/rc5.cpp
parent428471d39fb8c205a9fad899c88c30a2cb7df685 (diff)
parent10affea371406c0ae4c080e5a19390a8e9bd154b (diff)
downloadcompass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.tar.gz
compass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.zip
Merge branch 'mbedtls'
Replace Crypto++ 5.6.2 with Mbed TLS 3.6.0 Newer compilers are starting to show the age of the crypto library we've been using, as it is sometimes a pain to recompile compass lately. So, the tracked version of Crypto++ was at least due for an upgrade. However, I plan to soon begin reimplementing compass in C. So, I'm taking this opportunity to first just migrate the cryptography library to a newer C alternative. This branch does so, and integrates its use into the current C++ version of compass. * mbedtls: Remove unnecessary exception handler catch block Refactor random password generation to use mbedtls entropy source Refactor SHA256 function to use mbedtls Refactor AES functions to use mbedtls Add Mbedtls library Remove Crypto++ library
Diffstat (limited to '')
-rw-r--r--cryptopp562/rc5.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/cryptopp562/rc5.cpp b/cryptopp562/rc5.cpp
deleted file mode 100644
index 2b730de..0000000
--- a/cryptopp562/rc5.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-// rc5.cpp - written and placed in the public domain by Wei Dai
-
-#include "pch.h"
-#include "rc5.h"
-#include "misc.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-void RC5::Base::UncheckedSetKey(const byte *k, unsigned int keylen, const NameValuePairs &params)
-{
- AssertValidKeyLength(keylen);
-
- r = GetRoundsAndThrowIfInvalid(params, this);
- sTable.New(2*(r+1));
-
- static const RC5_WORD MAGIC_P = 0xb7e15163L; // magic constant P for wordsize
- static const RC5_WORD MAGIC_Q = 0x9e3779b9L; // magic constant Q for wordsize
- static const int U=sizeof(RC5_WORD);
-
- const unsigned int c = STDMAX((keylen+U-1)/U, 1U); // RC6 paper says c=1 if keylen==0
- SecBlock<RC5_WORD> l(c);
-
- GetUserKey(LITTLE_ENDIAN_ORDER, l.begin(), c, k, keylen);
-
- sTable[0] = MAGIC_P;
- for (unsigned j=1; j<sTable.size();j++)
- sTable[j] = sTable[j-1] + MAGIC_Q;
-
- RC5_WORD a=0, b=0;
- const unsigned n = 3*STDMAX((unsigned int)sTable.size(), c);
-
- for (unsigned h=0; h < n; h++)
- {
- a = sTable[h % sTable.size()] = rotlFixed((sTable[h % sTable.size()] + a + b), 3);
- b = l[h % c] = rotlMod((l[h % c] + a + b), (a+b));
- }
-}
-
-typedef BlockGetAndPut<RC5::RC5_WORD, LittleEndian> Block;
-
-void RC5::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
-{
- const RC5_WORD *sptr = sTable;
- RC5_WORD a, b;
-
- Block::Get(inBlock)(a)(b);
- a += sptr[0];
- b += sptr[1];
- sptr += 2;
-
- for(unsigned i=0; i<r; i++)
- {
- a = rotlMod(a^b,b) + sptr[2*i+0];
- b = rotlMod(a^b,a) + sptr[2*i+1];
- }
-
- Block::Put(xorBlock, outBlock)(a)(b);
-}
-
-void RC5::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
-{
- const RC5_WORD *sptr = sTable.end();
- RC5_WORD a, b;
-
- Block::Get(inBlock)(a)(b);
-
- for (unsigned i=0; i<r; i++)
- {
- sptr-=2;
- b = rotrMod(b-sptr[1], a) ^ a;
- a = rotrMod(a-sptr[0], b) ^ b;
- }
- b -= sTable[1];
- a -= sTable[0];
-
- Block::Put(xorBlock, outBlock)(a)(b);
-}
-
-NAMESPACE_END