neilsagarwal / hpc Goto Github PK
View Code? Open in Web Editor NEWPython Implementation of Hasty Pudding Cipher (HPC)
License: MIT License
Python Implementation of Hasty Pudding Cipher (HPC)
License: MIT License
In the Richard Schroeppel's page about HPC there are some citations about more than one KX Table in the cipher:
"Although indefinite size keys are allowed, there are in effect only 2^16384 distinct keys. (If all five tables are considered, then there are 81920 bits of key.)"
/\ https://web.archive.org/web/20211130025215if_/http://richard.schroeppel.name:8015/hpc/hpc-overview
"Each subcipher has a KX (key expansion) table, 256 words of 64-bits, pseudo-randomly generated from the key. All five tables may be computed when a key is setup, or the tables may be computed when needed. An application which only used a few blocksizes would need only a subset of the tables. The same algorithm is used for each KX table, changing only an initialization. The KX tables are firewalled: knowing a KX table won't help find the original key, or a KX table for a different subcipher."
/\ https://web.archive.org/web/20120722092329/http://richard.schroeppel.name:8015/hpc/
==============================================
It would be a good idea to implement it.
I found at this page (https://www.schneier.com/books/applied-cryptography-source), this file which is a C implementation of HPC: https://www.schneier.com/wp-content/uploads/2015/03/HPC-2.zip
It mixes up to 256bits of a key with the KX table.
l_key[0][1] ^= io_swap(in_key[0]); l_key[0][0] ^= io_swap(in_key[1]);
l_key[1][1] ^= io_swap(in_key[2]); l_key[1][0] ^= io_swap(in_key[3]);
if(key_len > 128)
{
l_key[2][1] ^= io_swap(in_key[4]); l_key[2][0] ^= io_swap(in_key[5]);
}
if(key_len > 192)
{
l_key[3][1] ^= io_swap(in_key[6]); l_key[3][0] ^= io_swap(in_key[7]);
}
After that, the 249th 64 bit word is processed in the algorithm:
for(i = 0; i < 8; ++i)
{
s[i][0] = l_key[248 + i][0]; s[i][1] = l_key[248 + i][1];
}
I'm really confused, the author says it's a variable key size cipher, as I read in this C implementation the maximum key size could be 248 words of 64 bits (15872 bit key), am I right?
What is the largest key size accepted by HPC? Do you know?
Traceback (most recent call last):
......
in medium_encrypt
s1 = m_add(ptxt[1], kx[blocksize+1]) & lmask
IndexError: list index out of range
The ptxt of the incoming function exists only ptxt[0], not ptxt[1]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.