JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html
https://ftsafe.en.alibaba.com/index.html
How to implement X9.63 with bouncycastle libarary
-
- Posts: 4
- Joined: Fri Jun 15, 2018 5:33 am
- Points :62
- Contact:
How to implement X9.63 with bouncycastle libarary
Hello,
Does anybody know how to implement X9.63 with bouncycastle libarary?
Does anybody know how to implement X9.63 with bouncycastle libarary?
-
- Posts: 39
- Joined: Wed Aug 31, 2016 9:55 pm
- Points :372
- Contact:
Re: How to implement X9.63 with bouncycastle libarary
A demo like this:iSmartcard wrote: ↑Tue Aug 21, 2018 1:23 amHello,
Does anybody know how to implement X9.63 with bouncycastle libarary?
Code: Select all
/**
* X9.63 key derivation function, Derive AES Session key from secret and
* sharedInfo.
*
* @param zab
* secret
* @param sharedInfo
* sharedInfo
* @param keydatalen
* the byte length of the keying data to generate.e.g. 16*5
* @return 5 keys
*/
public static byte[] deriveFunction(byte[] za, byte[] zb, byte[] sharedInfo, int keyDataLen) {
int len = za.length + zb.length;
byte[] secret = new byte[len];
byte[] keys = new byte[keyDataLen];
short offset = 0;
System.arraycopy(za, 0, secret, offset, za.length);
offset += za.length;
System.arraycopy(zb, 0, secret, offset, zb.length);
offset += zb.length;
SHA256Digest hash = new SHA256Digest();
KDF2BytesGenerator kdf = new KDF2BytesGenerator(hash);
kdf.init(new KDFParameters(secret, sharedInfo));
kdf.generateBytes(keys, (short) 0, keyDataLen);
return keys;
}
Who is online
Users browsing this forum: Google [Bot] and 51 guests