All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bugvm.bouncycastle.cert.selector.MSOutlookKeyIdCalculator Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
package com.bugvm.bouncycastle.cert.selector;

import java.io.IOException;

import com.bugvm.bouncycastle.asn1.ASN1Encoding;
import com.bugvm.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import com.bugvm.bouncycastle.crypto.Digest;
import com.bugvm.bouncycastle.crypto.digests.SHA1Digest;

class MSOutlookKeyIdCalculator
{
    static byte[] calculateKeyId(SubjectPublicKeyInfo info)
    {
        Digest dig = new SHA1Digest();    // TODO: include definition of SHA-1 here
        byte[] hash = new byte[dig.getDigestSize()];
        byte[] spkiEnc = new byte[0];
        try
        {
            spkiEnc = info.getEncoded(ASN1Encoding.DER);
        }
        catch (IOException e)
        {
            return new byte[0];
        }

        // try the outlook 2010 calculation
        dig.update(spkiEnc, 0, spkiEnc.length);

        dig.doFinal(hash, 0);

        return hash;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy