JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html

How to implement X9.63 with bouncycastle libarary

JavaCard Applet Development Related Questions and Answers.
iSmartcard
Posts: 4
Joined: Fri Jun 15, 2018 5:33 am
Points :62
Contact:

How to implement X9.63 with bouncycastle libarary

Post by iSmartcard » Tue Aug 21, 2018 1:23 am

Hello,
Does anybody know how to implement X9.63 with bouncycastle libarary?

scplatform
Posts: 39
Joined: Wed Aug 31, 2016 9:55 pm
Points :372
Contact:

Re: How to implement X9.63 with bouncycastle libarary

Post by scplatform » Tue Aug 21, 2018 1:26 am

iSmartcard wrote:
Tue Aug 21, 2018 1:23 am
Hello,
Does anybody know how to implement X9.63 with bouncycastle libarary?
A demo like this:

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;
	}

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Google [Bot] and 43 guests

JavaCard OS : Disclaimer