I've been provided with a java.util.String
32 characters length. The String
contains 16 pairs of hexadecimal characters which represent the key that I should use on an AES and CMAC message signature creation.
I've a problem getting the correct message signed with the provided key, I'm using 'bouncycastle' library. I show you my code:
KeyParameter parameter = new KeyParameter(KEY.getBytes(StandardCharsets.UTF_8));
AESEngine aes = new AESEngine();
CMac mac = new CMac(aes);
mac.init(parameter);
mac.update(message.getBytes(StandardCharsets.UTF_8), 0, message.getBytes(StandardCharsets.UTF_8).length);
byte[] out = new byte[mac.getMacSize()];
mac.doFinal(out, 0);
A partner is implementing this very code in C# with the same library. We found that byte in java has signed number representation although C# don't. Trying to make parallel implementation of this get's me a bit disoriented.
I'm able to get the proper int[]
from 0 to 255 values that my partner gets when processing the key.