You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tuweni.apache.org by "Antoine Toulme (Jira)" <ji...@apache.org> on 2019/12/16 08:43:00 UTC

[jira] [Updated] (TUWENI-30) Crypto GenericHash does NOT allow for setting a key

     [ https://issues.apache.org/jira/browse/TUWENI-30?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antoine Toulme updated TUWENI-30:
---------------------------------
    Fix Version/s: 1.0.0

> Crypto GenericHash does NOT allow for setting a key
> ---------------------------------------------------
>
>                 Key: TUWENI-30
>                 URL: https://issues.apache.org/jira/browse/TUWENI-30
>             Project: Tuweni
>          Issue Type: Bug
>            Reporter: Brian Demers
>            Priority: Major
>             Fix For: 1.0.0
>
>
> The GenericHash class in the `crytpo` module does NOT allow setting the key/key length when hashing a BLAKE2b.
>  
> Maybe expose something like `GenericHash.hash(int hashLength, Input input, Input key)`?
>  
> This monstrosity is my current workaround:
> {code:java}
>     public static byte[] hash(int hashLength, byte[] bytes, byte[] key) {        // static int crypto_generichash_blake2b(byte[] out, long outlen, byte[] in, long inlen, byte[] key, long keylen)        byte[] output = new byte[hashLength];        try {
>             Method blake2b = Sodium.class.getDeclaredMethod("crypto_generichash_blake2b",
>                     byte[].class, long.class,
>                     byte[].class, long.class,
>                     byte[].class, long.class);            blake2b.setAccessible(true);
>             blake2b.invoke(null,
>                            output, output.length,
>                            bytes, bytes.length,
>                            key, key.length);            return output;        } catch (NoSuchMethodException e) {
>             throw new IllegalStateException("Failed to find method 'crypto_generichash_blake2b' in: " + Sodium.class, e);
>         } catch (IllegalAccessException | InvocationTargetException e) {
>             throw new IllegalStateException("Failed to calculate BLAKE2b digest", e);
>         }
>     } {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@tuweni.apache.org
For additional commands, e-mail: issues-help@tuweni.apache.org