1package org.bouncycastle.cert.selector; 2 3import java.io.IOException; 4 5import org.bouncycastle.asn1.ASN1Encoding; 6import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; 7import org.bouncycastle.crypto.Digest; 8import org.bouncycastle.crypto.digests.SHA1Digest; 9 10class MSOutlookKeyIdCalculator 11{ 12 static byte[] calculateKeyId(SubjectPublicKeyInfo info) 13 { 14 Digest dig = new SHA1Digest(); // TODO: include definition of SHA-1 here 15 byte[] hash = new byte[dig.getDigestSize()]; 16 byte[] spkiEnc = new byte[0]; 17 try 18 { 19 spkiEnc = info.getEncoded(ASN1Encoding.DER); 20 } 21 catch (IOException e) 22 { 23 return new byte[0]; 24 } 25 26 // try the outlook 2010 calculation 27 dig.update(spkiEnc, 0, spkiEnc.length); 28 29 dig.doFinal(hash, 0); 30 31 return hash; 32 } 33} 34