jangko / nimaes Goto Github PK
View Code? Open in Web Editor NEWAdvanced Encryption Standard, Rinjdael Algorithm written in Nim
Advanced Encryption Standard, Rinjdael Algorithm written in Nim
For cryptCTR, if "nc_of" is not zero, as "stream_block" is initialized with zeroes, the beginning of the text is not encrypted.
Here is a small program which shows the error.
import nimAES
var cipher = initAES()
let key = "abcdefghijklmnop"
discard cipher.setEncodeKey(key)
let text = "Some text to show that there is an error."
echo "Text -> ", text
var offset: int = 0
var nonce = "0123456701234567"
var encrypted = cipher.cryptCTR(offset, nonce, text[0..20])
encrypted &= cipher.cryptCTR(offset, nonce, text[21..text.high])
echo "Encrypted -> ", encrypted
offset = 0
nonce = "0123456701234567"
var decrypted = cipher.cryptCTR(offset, nonce, encrypted)
echo "Decrypted -> ", decrypted
To solve the issue, it will be necessary to initialize "stream_block" with the last encrypted value of
the nonce, so, probably, to keep it in the context.
Note that there is no such problem with CFB128 mode as the offset is applied on the IV itself.
This error seems to occure with new nim 1.2.0 everytime I try to use setDecodeKey
Specifics :
filename = 0x56667a5c"/home/kittytechno/.nimble/pkgs/nimAES-0.1.2/nimAES.nim"], [procname = 0x56667aa0"setEncodeKey",
line = 184,
filename = 0x56667a5c"/home/kittytechno/.nimble/pkgs/nimAES-0.1.2/nimAES.nim"], [procname = 0x56662060"sysFatal",
line = 49,
filename = 0x56662069"/home/kittytechno/.choosenim/toolchains/nim-1.2.0/lib/system/fatal.nim"], [procname = nil,
line = -10,
Output from $ nimble install nimaes
Downloading https://github.com/jangko/nimAES using git Warning: File inside package 'nimAES' is outside of permitted namespace, should be named 'nimAES.nim' but was named 'test.nim' instead. This will be an error in the future. Hint: Rename this file to 'nimAES.nim', move it into a 'nimAES/' subdirectory, or prevent its installation by adding
skipFiles = @["test.nim"]to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info. Verifying dependencies for [email protected] Installing [email protected] Success: nimAES installed successfully.
Still seems to work ok, just maybe update to the language styling.
Cheers
you have assert in one of encryptECB proc and another encryptECB encrypts only first 16 bytes. why?
Hey :)
I encountered a bug in CBC mode - tried to encrypt and decrypt a string, but seems like the first bytes are not decrypted well.
the code:
import nimAES
let communication_aes_key = "ieMhfhf!!56=z$V4fd*3t15f3.3ZZaw3"
let communication_aes_iv = "-+x3BBw3NN_=!s32"
proc encrypt_cbc(plain_text: string): string =
var aes = initAES()
if aes.setEncodeKey(communication_aes_key):
let cipher_text = aes.encryptCBC(communication_aes_iv, plain_text)
return cipher_text
proc decrypt_cbc(cipher_text: string): string =
var aes = initAES()
if aes.setDecodeKey(communication_aes_key):
let plain_text = aes.decryptCBC(communication_aes_iv, cipher_text)
return plain_text
let encrypted = encrypt_cbc("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
let decrypted = decrypt_cbc(encrypted)
echo decrypted
Thanks in advance :)
When compiling any Nim program using NimAES, a very large .c file is generated (several MBs), which takes a long time to compile, uses up a large amount of memory during compilation making it impossibly ble to compile on low-memory systems (500-1000MB of RAM) and results in bigger executables.
This can be observed even when compiling the test program in this repository.
I never encountered this behavior in previous versions of Nim. Any idea why this is happening now?
Edit: i am an idiot
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.