Giter VIP home page Giter VIP logo

nimaes's People

Contributors

jangko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nimaes's Issues

"cryptCTR" yields a wrong result if parameter "nc_of" is not zero

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.

value out of range: 2298651006 notin -2147483648 .. 2147483647

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,

nim 0.17.0 nimble installation warning

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 addingskipFiles = @["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

Bug in decryption first bytes in CBC mode

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 :)

image

Nim 0.18.0 compilation problem

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.