I'm not sure if there's something I'm doing improperly, but I tried instantiating a CBC[blowfish] context and .init() doesn't seem to work:
import nimcrypto/blowfish
import nimcrypto/bcmode
var cbc: CBC[blowfish]
var key: string = "1234123412ABCDEF"
var iv: string = "ABCDEF1234123412"
var message: cstring = "hello"
var decrypted: cstring = cast[cstring](alloc0(100))
var encrypted: cstring = cast[cstring](alloc0(100))
cbc.init(key.toOpenArrayByte(0, key.len-1), iv.toOpenArrayByte(0, iv.len-1))
cbc.encrypt(cast[ptr byte](message), cast[ptr byte](encrypted), 100)
echo encrypted
echo cbc.decrypt(cast[ptr byte](encrypted), cast[ptr byte](decrypted), 100)
echo decrypted
dealloc(decrypted)
dealloc(encrypted)
Here's the build output:
cbcblowfishdemo.nim(37, 4) template/generic instantiation of `init` from here
nimcrypto/bcmode.nim(292, 9) template/generic instantiation of `assert` from here
nimcrypto/bcmode.nim(257, 16) Error: undeclared field: 'cipher'
This seems to result from the following function in bcmode.nim:
template sizeBlock*[T](ctx: CBC[T]): int =
## Size of ``CBC[T]`` block in octets (bytes). This value is equal
## to cipher ``T`` block size.
mixin sizeBlock
sizeBlock(ctx.cipher) # Error: undeclared field: 'cipher'
However, I have no idea why it can't see the cipher field (even when I try changing it to be a public member of CBC).
Any idea why it errors or if I'm initializing it improperly?
I'm not sure if there's something I'm doing improperly, but I tried instantiating a
CBC[blowfish]context and.init()doesn't seem to work:Here's the build output:
This seems to result from the following function in
bcmode.nim:However, I have no idea why it can't see the
cipherfield (even when I try changing it to be a public member ofCBC).Any idea why it errors or if I'm initializing it improperly?