[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [iaik-jce] Subject Key Identifier Extension

In the new release of IAIK-JCE (coming this week) the SubjectKeyIdentifier
extension includes a constructor that calculates the key identifier from a
PublicKey(Info) according to RFC2459.

Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von Tobias Adamson
Gesendet: Mittwoch, 28. Juni 2000 18:17
An: iaik-jce@iaik.at
Betreff: [iaik-jce] Subject Key Identifier Extension

I'm wondering if anyone has got a good way of generating
the Subject Key identifier Extension from the Subjects Public Key.

"The keyIdentifier is composed of a four bit type field with
the value 0100 followed by the least significant 60 bits of the
SHA-1 hash of the value of the BIT STRING subjectPublicKey."

According to the RFC (above)
I should be able to do like this.

	byte[] keyEncoded = publicKey.getEncoded();
	MessageDigest sha = null;
	try {
		sha = MessageDigest.getInstance("SHA");
	} catch (java.security.NoSuchAlgorithmException e)

	byte[] hash_value = sha.digest();

	keyBitString = new BIT_STRING(hash_value);
	String shaBinaryString = keyBitString.getBinaryString();
	shaBinaryString = shaBinaryString.substring(100,160);
	shaBinaryString = "0100" + shaBinaryString;

	SubjectKeyIdentifier subjectKey =
	BIT_STRING subjectKeyBITSTRING = new BIT_STRING(subjectKey.get());
	String subjectKeyString = subjectKeyBITSTRING.egtBinaryString();

After this code shouldn't shaBinaryString have the same value as
Am I doing something totaly wrong?

Thanks before hand

Regards Tobias Adamson
Mailinglist-archive at

To unsubscribe send an email to listserv@iaik.at with the folowing content: