lt / PHP-Curve25519

Pure PHP implementation of Curve25519
MIT License
21 stars 2 forks source link

[Feature Request] Integration with php-encryption #6

Closed vzool closed 7 years ago

vzool commented 7 years ago

Hi,

I'm trying to use your library to exchange encryption keys, those keys are generated by php-encryption library but I'm facing issues that shared keys were generated by PHP-Curve25519 are Pure Bytes and it should be implement some rules provided by php-encryption to ensure key security & integrity.

Are you interesting to integrate and enhance your library feature?

Thanks

lt commented 7 years ago

Not 100% sure what you're saying.

You've used another library to generate keys for this library and they're not compatible?

A quick look at their Key class, keys are constructed with raw bytes, and have a getRawBytes() method.

Unsure what "rules" you are referring to, there is nothing inherently insecure about the keys generated with 32 bytes from random_bytes as I recommend in the README. Keys passed to the library are properly clamped per the reference implementation.

vzool commented 7 years ago

There are many rules existed in their Encoding class that used to import/export keys:

-------------------------------------
|        Binary Key Structure        |
|------------------------------------|
|   header  |   bytes   |  hashing   |
|------------------------------------|

------------------------------------
|        Hashing Structure          |
|-----------------------------------|
|   algo  |   header   |   bytes    |
|-----------------------------------|

As they have use a hash_hmac while encrypting and decrypting data.

-------------------------------------
|      Encrypted Data Structure      |
|------------------------------------|
|     ciphertext   |    AUTH HMAC    |
|------------------------------------|

And ciphertext has many sections as well.

lt commented 7 years ago

Ok, I don't see why this library needs a way to extract keys out of another libraries format, they should be providing that functionality for you, verify/decode your data, get the raw bytes and pass it in as normal.

I don't have any intention of adding support for custom key formats so closing this.