Is there any vb6 library that uses hkdf and sha-512 - codeigniter

I am encrypting my data using AES-128 CBC. However it is decrypted by another software CodeIgnitor, which actually converts password into 2 elements. HMAC key and encryption_key using hkdf and SHA-512 digest.
How can i implement this thing in my code. (I am using VB 6)
Re-phrasing my question: How is password converted into 2 elements HMAC_key and encryption_key?
Let's see if I can explain further..
Encryption software used is CryptoSys while decryptionis done by CodeIgnitor..which is not working
So the difference I can see between the two is that codeignitor is expecting an HMAC authmessage when decrypting while the encryption does not prepend it the final message. So how can i do that? I am using VB6 for encryption.
So far I have come to the conclusion that there could be 2 key-derivation function a pb-kdf or a h-kdf.
The h-kdf authentication in particular works as follows:
A password is enterd by user
Based on this password and a random IV, an HMAC key is generated using HKDF and SHA-512 digest algo.
This HMAC key is saved and also expanded and then using IV/salt encrypts the plaintext message.
The IV is pre-pended to the plain-text message and base64 encoded.
The HMAC key is then pre-pended to the final message gereated in step 4.
So basically hkdf does not convert a key into 2 elements but only uses the basic key generated to generate other keys (and HMAC key is the original key used to generate other keys) now my question becomes...
Is there any vb6 library that uses hkdf and sha-512? As far as i have researched, Chilkat and CryptoSys APIs are only pbkdf based..Am I correct?

Related

Ruby: Decrypt content encrypted with AES algorithm which uses ECB mode and PKCS5 padding

I am calling an API which gives me back a string encrypted using AES algorithm. The result of AES algorithm is encoded using Base64. The AES algorithm uses ECB mode and PKCS5 padding.
With ruby decrypting AES is rather easy. So I tried the usual ways:
Tried the AES gem by chicks
Digged through the Cipher documentation to find a suitable algorithm
I ended up with a lot of "try and error" because it was not totally clear to me how to pass PKCS5 padding into the decryption function.
All I found is this class which refers to PKCS5 but its not totally clear how to pass my key and content in there.
So I tried many possible AES/ECB combinations like this:
decipher = OpenSSL::Cipher::AES.new(128, :ECB)
decipher.key = Base64.decode64(key)
encrypted = Base64.decode64(encrypted)
decrypted = decipher.update(encrypted) + decipher.final
but this throws:
final': wrong final block length (OpenSSL::Cipher::CipherError)
I am not an encryption specialist so I am in a dead end here. Maybe you have a hint in the right direction.
How can I decrypt AES encrypted content using my key and ECB mode with PKCS5 padding?
Thank you!

How do I do deterministic RSA in Go

I have two go services, let's call them A and B. B holds an RSA key pair, while A only knows the public key. I want them to know if they agree on some value V.
I want to do this by having B encrypt encrypt V using the public key and have A do a comparison, but all the crytpo/rsa functions take an RNG which adds entropy and makes each hash of V different. That means I can't compare the hashes.
Is there a function in the go standard library that will deterministicly hash V?
Note: I can achieve this by using a fresh RNG seeded with the same value everytime I hash V, but I want to be able to compute this hash from other languages and that would tie me to Go's RNG.
I want to do this by having B encrypt encrypt V using the public key and have A do a comparison…
You're using the wrong primitive.
If you want the owner of a private key to prove that they have some data, have them Sign that data. The recipient can Verify that signature using the public key.
Use the SignPSS and VerifyPSS methods to do this. The signature will not be deterministic, but it doesn't need to be -- the recipient will still be able to verify it.
Take a look at the docs for EncryptOAEP:
The random parameter is used as a source of entropy to ensure that encrypting the same message twice doesn't result in the same ciphertext.
So the random data does not affect the reader's ability to decrypt the message with only the public key. The cipher text bytes will be different each time you encrypt the same value, which is a good thing.
Take a look at the examples on Encrypt/Decrypt OAEP in those docs. It should be sufficient to get you moving the right direction.

ECDH (256 bit key), Create Private Key from X component

I am trying to implement BitMessage Crypto with Windows CNG functions
I am trying to create a key pair from a single 32 byte value.
In order to encrypt the pubkey data, a double SHA-512 hash is calculated from the address version number, stream number, and ripe hash of the Bitmessage address that the pubkey corresponds to. The first 32 bytes of this hash are used to create a public and private key pair with which to encrypt and decrypt the pubkey data, using the same algorithm as message encryption (see Encryption).
Bitmessage Protocol regarding this
This can be done by using the 32 byte integer as the private key component.
But how can i do this using Windows CNG functions.
or maybe i can do the calculation manually?
Thanks for any input.
BCryptImportKeyPiar using a blank public key(X,Y), and use the random 32 byte number as the private part of the BCRYPT_ECCKEY_BLOB.
duh..

How to decrypt a string with known key and a IV in java?

I have a string that is encrypted in c#.net which I have to decrypt in java using a key and a IV provided by the client. Used algorithm is AES.
I have tried few things. The key looks something like
key = "QWEEqweASDreefERTfdf45fefdWERfsdf34fedfdwn5=" //length 44 bytes
iv = "nkfghER24dfdfdf56YUIgH==" // lenght=24 bytes
When I use this with Cipher class with algorith AES/CBC/PKCS5Padding
passing the above key to Secretkeyspec class it says invalid key lenth 44 bytes
I am not able makeout whats wrong with the key. Tried all suggested solutions for few days nothing works. Can some one help please? Thank you.
Use java native for C# code.
First write C# code for decrypt the key.
and calling the code in java using native.
for reference
http://www.codeproject.com/Articles/378826/How-to-wrap-a-Csharp-library-for-use-in-Java

"Recalculate" SHA512+salt string to BLOWFISH+salt - is this possible?

Maybe this is a stupid question, but I wouldn't be shocked if some excellent brains come around with a proper solution or an idea: Is it possible to recalculate/transcode a salted sha512 string into a salted blowfish string ?
The (imo quite interesting) background is: I have a big database of SHA512+salt strings like that $6$rounds=5000$usesomesillystri$D4IrlXatmP7rx3P3InaxBeoomnAihCKREY4... (118 chars) and want to move to another hash/salt algorithm, generating strings like $2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi (60 chars).
I'm intentionally NOT asking this on security.stackexchange.com as this is not a security question. It's about transcoding/recalculation.
Is it possible to recalculate/transcode a salted sha512 string into a salted blowfish string ?
Nope.
SHA2-512 is a cryptographic hash. Data goes in, but there's no way to get it back out. Do note that the thing you're using is a proposed but not standardized form of crypt that uses SHA2, and is not a raw SHA2 hash.
bcrypt (which is derived from, but is not Blowfish) is a key derivation function, which while a different thing than a cryptographic hash, still has the same result: data goes in, but there's no way to get it back out.
There is no way to simply convert one of these password hash types to another. This is true of almost every hash type. If you need to change the hash type, do so when the user next logs in.

Resources