Skip to content

New default KDF #83

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

Merged
merged 5 commits into from
Aug 16, 2019
Merged

New default KDF #83

merged 5 commits into from
Aug 16, 2019

Conversation

savely-krasovsky
Copy link
Member

@savely-krasovsky savely-krasovsky commented Aug 14, 2019

HKDF-HMAC-SHA256 instead of just SHA256

@codecov
Copy link

codecov bot commented Aug 14, 2019

Codecov Report

Merging #83 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #83   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           7      7           
  Lines         162    171    +9     
  Branches        5      5           
=====================================
+ Hits          162    171    +9
Impacted Files Coverage Δ
src/keys/PrivateKey.ts 100% <100%> (ø) ⬆️
src/index.ts 100% <100%> (ø) ⬆️
src/keys/PublicKey.ts 100% <100%> (ø) ⬆️
src/tests/crypt.test.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c837b2...ffacffa. Read the comment docs.

@savely-krasovsky savely-krasovsky changed the title New default KDF: HKDF-HMAC-SHA256 instead of just SHA256 New default KDF Aug 14, 2019
@kigawas
Copy link
Member

kigawas commented Aug 14, 2019

Can you add some test cases?

@savely-krasovsky
Copy link
Member Author

@kigawas it tests against your Python backend, I cannot fix it.

@kigawas
Copy link
Member

kigawas commented Aug 14, 2019

ecies/py#87

@savely-krasovsky
Copy link
Member Author

@kigawas did you test it with JS one?

@kigawas
Copy link
Member

kigawas commented Aug 14, 2019

I'll test it later today

@kigawas
Copy link
Member

kigawas commented Aug 14, 2019

    def test_hdkf(self):
        k1 = PrivateKey(secret=bytes([2]))
        self.assertEqual(k1.to_int(), 2)

        k2 = PrivateKey(secret=bytes([3]))
        self.assertEqual(k2.to_int(), 3)

        self.assertEqual(
            encapsulate(k1, k2.public_key), decapsulate(k1.public_key, k2)
        )
        self.assertEqual(
            encapsulate(k1, k2.public_key).hex(),
            '6f982d63e8590c9d9b5b4c1959ff80315d772edd8f60287c9361d548d5200f82'
        )

@savely-krasovsky
Copy link
Member Author

@kigawas if you were surprised with encapsulate/decapsulate syntax, I took it from google's tink, because we need same public key. KEM is just key encapsulation mechanism. ECIES is basically KEM+DEM (data encapsulation mechanism).

@savely-krasovsky
Copy link
Member Author

savely-krasovsky commented Aug 16, 2019

@kigawas let me know when you will have deployed new Python backend at Heroku. I want to test Go version against it.

@kigawas
Copy link
Member

kigawas commented Aug 16, 2019

@L11r
Already deployed

@savely-krasovsky
Copy link
Member Author

savely-krasovsky commented Aug 16, 2019

@kigawas if so, JS tests still fail 🤔
AES-GCM cannot decrypt data.
(node:109) UnhandledPromiseRejectionWarning: Error: Unsupported state or unable to authenticate data

@kigawas
Copy link
Member

kigawas commented Aug 16, 2019

I'll fix js version, wait a sec

@kigawas
Copy link
Member

kigawas commented Aug 16, 2019

Looks ok for now.
Basically the reason is ecdhUnsafe was returning compressed public key format

@savely-krasovsky
Copy link
Member Author

@kigawas yeah, already got it. Will fix Go version soon.

@kigawas
Copy link
Member

kigawas commented Aug 16, 2019

        derived = HKDF(b'secret', 32, b'', SHA256).hex()
        self.assertEqual(
            derived,
            "2f34e5ff91ec85d53ca9b543683174d0cf550b60d5f52b24c97b386cfcf6cbbf"
        )

You can use this to check hkdf

@savely-krasovsky
Copy link
Member Author

@kigawas yeah, already done.

ecies/go#3

@kigawas kigawas merged commit e7d2dfb into master Aug 16, 2019
@kigawas kigawas deleted the new-kdf branch August 16, 2019 07:54
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

Successfully merging this pull request may close these issues.

2 participants