On Mon, Dec 11, 2017 at 12:46:59AM +0800, Ben Coman wrote:
> where the "EVP function provide a high level interface to OpenSSL
> cryptographic functions."

Hi Ben,

As it happened, over the weekend I implemented the Pharo wrappers for the
EVP_DigestSign* and EVP_DigestVerify* APIs. It is straightforward to add the
non-public key-using message digest functions, so I've just done it. Code
snippets:

  | msg st c |
  msg := 'Grumpy wizards make toxic brew for the evil Queen and Jack.'.
  st := SHA256 hashMessage: msg asByteArray.
  c := LcEvpSHA256 new hashMessage: msg asByteArray.
  st = c
  => true

Using Sven's example:

  | msg st c |
  key := ByteArray new: 32.
  msg := 'Grumpy wizards make toxic brew for the evil Queen and Jack.'.
  st := (HMAC on: SHA256) key: key; digestMessage: msg asByteArray.
  c := (HMAC on: LcEvpSHA256) key: key; digestMessage: msg asByteArray.
  st = c
  => true

Code at http://smalltalkhub.com/#!/~PierceNg/OpenSSL-Pharo.

I've also added tests for SHA256 similar to the snippets above.  I will add
SHA512 tests when I find the test vectors.

In the next two weeks when I have some time off from work, I will attempt to
move the repo to GH. Meanwhile, I've added you as a contributor to the STH
repo if you'd like to hack on it.

Pierce


Reply via email to