Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd behaviour (including SIGSEGV) from encryptedCreateDirectWithTweak #67

Open
Anviking opened this issue Feb 18, 2020 · 0 comments
Open

Comments

@Anviking
Copy link
Contributor

Setup

stack ghci --test cardano-crypto:cardano-crypto-test
import Cardano.Crypto.Wallet.Encrypted
:set -XOverloadedStrings
import qualified Data.ByteString as BS
bytes = "(\134\242|I\141L\EM\NUL\128\173\252q\191\172\167>f \218\222\167.\136\DC4\216\191\253r8cD8&I\STX;\185&\177\172E\241\185\241\157\226\r\163+\EM\GS\232-\188\250[E^N\129J\158\STX\134\188!\241\DLEzt\222\199\247U\143\ETB\128,\226Q\"\230\234\"\191\177\250\230\167\n\214X\244z\\" :: BS.ByteString
pwd = "" :: BS.ByteString

Oddness 1

BS.take 1 on input does not affect output:

λ> k1 = unEncryptedKey $ encryptedCreateDirectWithTweak bytes pwd
λ> k2 = unEncryptedKey $ encryptedCreateDirectWithTweak (BS.take 1 bytes) pwd
λ> k1 == k2
True -- 🧐

Oddness 2

BS.take 0 on input causes SIGSEGV.

λ> unEncryptedKey $ encryptedCreateDirectWithTweak (BS.take 0 bytes) pwd
"fish: 'stack ghci --test cardano-crypt…' terminated by signal SIGSEGV (Address boundary error)

Comment

It is mentioned in the doc-comment that the input must be 96 bytes long. Are these findings as expected?
https://github.com/input-output-hk/cardano-crypto/blob/3c5db489c71a4d70ee43f5f9b979fcde3c797f2a/src/Cardano/Crypto/Wallet/Encrypted.hs#L95-L96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant