How does speck cipher 64-96 works, I tried to read so many papers but I am not getting the algorithm. how to implement it in c programming?
SPECK64 and SPECK128 are lightweight block ciphers designed by Ray Beaulieu, Douglas Shors, Jason Smith, Stefan Treatman-Clark, Bryan Weeks and Louis Wingers. The SIMON and SPECK homepage is located at http://iadgov.github.io/simon-speck. The ciphers were designed for resource constrained devices and gadgets that participate in the Internet of Things. NIST is considering applications of lightweight cryptography for sensor networks, healthcare and the smart grid. NASA has expanding programs for small satellites such as CubeSats which may need lightweight algorithms. Finally, Linux added SPECK support for efficient, opportunistic encryption on low-resource devices to the kernel in February 2018.
One of the security goals of SPECK was maintain an acceptable level of security in an environment where power, memory and processors were [sometimes severely] limited. The ciphers are associated with the NSA so there is some controversy about them. The ciphers also have a number of good attributes so speculation should not be hard to overcome. Also see Notes on the design and analysis of Simon and Speck. Also see Notes on the design and analysis of Simon and Speck.
SPECK-128 offers a specialized SSSE3 implementation for AMD and Intel that runs around 2.3 cycles per byte (cpb) on a modern Intel core; see Commit e7fee716d68a. SPECK-128 also provides a NEON based implementation for ARM A-32 that runs around 10 cpb; see Commit 304809a65dc3. The Aarch64 implementation also runs around 7.4 cpb; see Commit 304809a65dc34a.
If your project is using encryption alone to secure your data, encryption alone is usually not enough. Please take a moment to read Authenticated Encryption and understand why you should prefer to use CCM, GCM, or EAX over other modes, such as CBC or CTR.
Note: Simon and Speck were added at Crypto++ 6.0. We call the 6.0 implementation the "big-endian" implementation because it arrived at the test vector results published in the paper, and the test vectors were in big-endian format. Our implementation was wrong because we failed to follow the algorithmic description provided in the paper. At Crypto++ 6.1 we switched to a "little-endian" implementation, which followed the algorithmic description from the the paper. The little-endian version fails to arrive at the test vector results, but it agrees with the paper and the kernel's implementation. Also see Issue 585.
Algorithm Name
If you call StaticAlgorithmName then the function will return the partial name "SPECK-<block size>". Once the cipher is keyed you can call AlgorithmName which returns the full name presented as "SPECK-<block size>(<key length>)". In the case of SPECK the algorithms names are SPECK-64(96), SPECK-64(128), SPECK-128(128), SPECK-128(192) and SPECK-128(256).
The naming follows DSTU 7624:2014, where block size is provided first and then key length. The library uses a dash to identify block size and parenthesis to identify key length. For example, Kalyna-128(256) is Kalyna with a 128-bit block size and a 256-bit key length. If a mode is associated with the object, then it follows as expected. For example, Kalyna-256(512)/ECB denotes Kalyna with a 256-bit block and 512-bit key operated in ECB mode.
int main(int argc, char* argv[])
{
SPECK128::Encryption speck;
std::cout << "StaticAlgorithmName: " << speck.StaticAlgorithmName() << std::endl;
std::cout << "AlgorithmName (unkeyed): " << speck.AlgorithmName() << std::endl;
byte key[SPECK128::DEFAULT_KEYLENGTH] = {};
speck.SetKey(key, sizeof(key));
std::cout << "AlgorithmName (keyed): " << speck.AlgorithmName() << std::endl;
return 0;
}
The program results in the following output.
$ ./test.exe StaticAlgorithmName: SPECK-128 AlgorithmName (unkeyed): SPECK-128 AlgorithmName (keyed): SPECK-128(128)
Sample Programs
There are three sample programs. The first shows SPECK key and block sizes. The second and third use filters in a pipeline. Pipelining is a high level abstraction and it handles buffering input, buffering output and padding for you.
If you are benchmarking then you may want to visit Benchmarks | Sample Program . It shows you how to use StreamTransformation::ProcessString method to process blocks at a time. Calling a cipher's ProcessString or ProcessBlock eventually call a cipher's ProcessAndXorBlock or AdvancedProcessBlocks, and they are the lowest level API you can use.
The first snippet dumps the minimum, maximum, and default key lengths used by SPECK128.
std::cout << "key length: " << SPECK128::DEFAULT_KEYLENGTH << std::endl; std::cout << "key length (min): " << SPECK128::MIN_KEYLENGTH << std::endl; std::cout << "key length (max): " << SPECK128::MAX_KEYLENGTH << std::endl; std::cout << "block size: " << SPECK128::BLOCKSIZE << std::endl;
Output from the above snippet produces the following. Notice the default key size is 128 bits or 16 bytes.
$ ./test.exe key length: 16 key length (min): 16 key length (max): 32 block size: 16
The following program shows how t operate SPECK128 in CBC mode using a pipeline. The key is declared on the stack using a SecByteBlock to ensure the sensitive material is zeroized. Similar could be used for both plain text and recovered text.
AutoSeededRandomPool prng;
SecByteBlock key(SPECK128::DEFAULT_KEYLENGTH);
prng.GenerateBlock(key, key.size());
byte iv[SPECK128::BLOCKSIZE];
prng.GenerateBlock(iv, sizeof(iv));
std::cout << "Key: ";
StringSource(key, key.size(), true, new HexEncoder(new FileSink(std::cout)));
std::cout << std::endl;
std::cout << "IV: ";
StringSource(iv, sizeof(iv), true, new HexEncoder(new FileSink(std::cout)));
std::cout << std::endl;
string plain = "CBC Mode Test";
string cipher, encoded, recovered;
/*********************************\
\*********************************/
try
{
std::cout << "plain text: " << plain << std::endl;
CBC_Mode< SPECK128 >::Encryption e;
e.SetKeyWithIV(key, key.size(), iv);
// The StreamTransformationFilter adds padding
// as required. ECB and CBC Mode must be padded
// to the block size of the cipher.
StringSource(plain, true,
new StreamTransformationFilter(e,
new StringSink(cipher)
) // StreamTransformationFilter
); // StringSource
}
catch(const CryptoPP::Exception& e)
{
cerr << e.what() << std::endl;
exit(1);
}
// Pretty print
std::cout << "Cipher text: ";
StringSource(cipher, true, new HexEncoder(new FileSink(std::cout)));
std::cout << std::endl;
try
{
CBC_Mode< SPECK128 >::Decryption d;
d.SetKeyWithIV(key, key.size(), iv);
// The StreamTransformationFilter removes
// padding as required.
StringSource s(cipher, true,
new StreamTransformationFilter(d,
new StringSink(recovered)
) // StreamTransformationFilter
); // StringSource
std::cout << "recovered text: " << recovered << std::endl;
}
catch(const CryptoPP::Exception& e)
{
cerr << e.what() << std::endl;
exit(1);
}
A typical output is shown below. Note that each run will produce different results because the key and initialization vector are randomly generated.
$ ./test.exe Key: F36D4289293A07A0C1E3D8EAFBF83C6F IV: 50650B834D62457D3D5CBFE9708EC927 plain text: CBC Mode Test Cipher text: 952FB25AF03C17F972BEB9357AA48719 recovered text: CBC Mode Test
By switching to EAX mode, authenticity assurances can placed on the cipher text for nearly no programming costs. Below the StreamTransformationFilter was replaced by AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter.
EAX< SPECK128 >::Encryption e;
e.SetKeyWithIV(key, key.size(), iv);
StringSource(plain, true,
new AuthenticatedEncryptionFilter(e,
new StringSink(cipher)
) // StreamTransformationFilter
); // StringSource
...
EAX< SPECK128 >::Decryption d;
d.SetKeyWithIV(key, key.size(), iv);
StringSource s(cipher, true,
new AuthenticatedDecryptionFilter(d,
new StringSink(recovered)
) // StreamTransformationFilter
); // StringSource
Typical output is as follows. Notice the additional cipher text bytes due to the MAC bytes. See EAX Mode for details.
$ ./test.exe Key: 802F1C05845AAE68BA546A13442FA097 IV: 552EB9F4B252F2ABA24577124C18D26A plain text: EAX Mode Test Cipher text: E03C5BD43C94BB59772B4FF812556970EE926DAB965DF092750B8AA96A recovered text: EAX Mode Test
To manually insert bytes into the filter, perform multiple Puts. Though Get is used below, a StringSink could easily be attached and save the administrivia.
const size_t SIZE = 16 * 4;
string plain(SIZE, 0x00);
for(size_t i = 0; i < plain.size(); i++)
plain[i] = 'A' + (i%26);
...
CBC_Mode < SPECK128 >::Encryption encryption(key, sizeof(key), iv);
StreamTransformationFilter encryptor(encryption, NULL);
for(size_t j = 0; j < plain.size(); j++)
encryptor.Put((byte)plain[j]);
encryptor.MessageEnd();
size_t ready = encryptor.MaxRetrievable();
string cipher(ready, 0x00);
encryptor.Get((byte*) &cipher[0], cipher.size());
Validation
The Simon and Speck implementations can be tested with the cryptest.exe program. The program validates against modified test vectors from the Simon and Speck paper. Each test vector presented in the paper was modified to little-endian format.
There was one test vector for each block size and key size. After we had one working test vector we generated additional test vectors for later use. The additional test vectors are located at TestVectors/simon.txt and TestVectors/speck.txt.
The program used to generate the test vectors is available at Noloader | simon-speck-supercop. See the files simon-tv.cxx and speck-tv.cxx.
$ ./cryptest.exe tv speck Using seed: 1519379574 Testing SymmetricCipher algorithm SPECK-64/ECB. ................ Testing SymmetricCipher algorithm SPECK-64/CBC. .............. Testing SymmetricCipher algorithm SPECK-64/CTR. .............. Testing SymmetricCipher algorithm SPECK-128/ECB. ........................ Testing SymmetricCipher algorithm SPECK-128/CBC. ..................... Testing SymmetricCipher algorithm SPECK-128/CTR. ..................... Tests complete. Total tests = 110. Failed tests = 0.
A modified test vector from the Simon and Speck paper includes the work modified in the Source:
Source: Simon and Simon paper, Appendix C (modified) Comment: SPECK-64/ECB, 96-bit key Key: 00010203 08090A0B 10111213 Plaintext: 65616E73 20466174 Ciphertext: 6C947541 EC52799F
A Crypto++ generated test vector says so in the source:
Source: Crypto++ 6.0 generated Comment: SPECK-64/ECB, 96-bit key Key: F64F824B DA9DA2D0 D446ABE3 Plaintext: 48731C8B FE3260D4 Ciphertext: 55CABA8D E9F967C8
How does speck cipher 64-96 works, I tried to read so many papers but I am...
SO, how many protons, neutrons and electrons are there. I am so
lost, Please help me! We are discussing isotopes.
(A)= p +ñ 77 cape As² - 136 p=33 n=77-33 =p-c
I really need some help understaning how system verilog coding works in Cygwin I am a PC user, so I in order to have a linux version or an option to run commands I installed a program called Cygwin. This program currently allows me to run .cpp file and supposedly to run verilog (.v) and systemVerilog (.sv) file, but I am not able to or familiar with how to command call them from Cygwins terminal. I would also like to...
Plz solve this, I tried so many times i kept getting 0
or 6.5 and they were wrong, thank u in advance, rating will follow
for sure!
Two small metallic spheres, each of mass m-0.25 g, are suspended as pendulums by light strings from a common point as shown in the figure below. The spheres are given the same electric charge, and it is found that they come to equilibrium when each string is at an angle f 6 3.5...
Can you please explain how to do this?? I
tried something, but am unsure if it's even right. Thanks!
There are no units in process at the beginning of the period, 530 units in process at the end of the period that are 30% complete, and 2940 units transferred out during the period. Based on this information, how many units were started during the period under the weighted average method? 2940 2410 3470 O 3099
I
am using web assign so I am not sure if my answer is wrong or the
symbols I am using( please explain!!! Thank you
EXERCISE Suppose the charge at the center is now increased to +90, while the charge at the surface of the conductor is changed to +40. (Use the following as necessary: ,, π, o and r.) HINTS: GETTING STARTED I'M STUCK! (a) Find the electric field exterior to the sphere, for r > b. 13(0 9(2x...
300 words minimum please and be neat so i am able to read
it.
Essay 7 topic: Explain in your own words, why do you think so many people in present-day America believe that SCIENCE is not important, and that it is not worth the effort to learn. Is this negative opinion of SCIENCE socially harmful or not? Explain what you believe could be done to change these people's negative opinions of science.
I am trying to implement this version of quicksort in C/c++ but I am getting stuck. Below is how the algorithm is supposed to work. This is the partitioning scheme I am trying to implement. 17, -10, 7, 19, 21, 23, -13, 31, 59 # ^ ^ start 17, -10, 7, 19, 21, 23, -13, 31, 59 # ^ ^ move left pointer to first element larger than pivot. 3 compares 17, -10, 7, 19, 21, 23, -13, 31, 59...
Should I kill myself? I feel worthless all the time because I hate how I am and how I'm treated. I have been to to therapy many times but it never helped and my illness is not curable. My personality is so shy and awkward and when I'm around people and I can barely talk to them. I don't have anyone to talk to and nobody cares about me. My family is always angry and doesn't give a ****. I'm...
does anybody have an idea of how many amps this equipment may be ?
i have tried googling this item but no luck on the specs. Anybody
have an idea of what this is or any similar products to it ?
Sungpath O