Exemplo n.º 1
0
        /**
         *
         * Calulates the keyidentifier using a SHA1 hash over the BIT STRING
         * from SubjectPublicKeyInfo as defined in RFC2459.
         *
         * Example of making a AuthorityKeyIdentifier:
         * <pre>
         *   SubjectPublicKeyInfo apki = new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(
         *       publicKey.getEncoded()).readObject());
         *   AuthorityKeyIdentifier aki = new AuthorityKeyIdentifier(apki);
         * </pre>
         *
         **/
        public AuthorityKeyIdentifier(
            SubjectPublicKeyInfo spki)
        {
            byte[] bytes  = spki.PublicKeyData.GetBytes();
            byte[] resBuf = Digests.DoFinal(new Sha1Digest(), bytes, 0, bytes.Length);

            this.keyidentifier = new DerOctetString(resBuf);
        }
Exemplo n.º 2
0
        /**
         * create an AuthorityKeyIdentifier with the GeneralNames tag and
         * the serial number provided as well.
         */
        public AuthorityKeyIdentifier(
            SubjectPublicKeyInfo spki,
            GeneralNames name,
            BigInteger serialNumber)
        {
            byte[] bytes  = spki.PublicKeyData.GetBytes();
            byte[] resBuf = Digests.DoFinal(new Sha1Digest(), bytes, 0, bytes.Length);

            this.keyidentifier = new DerOctetString(resBuf);
            this.certissuer    = name;
            this.certserno     = new DerInteger(serialNumber);
        }
Exemplo n.º 3
0
 public bool HasTestPassed(IXof digest)
 {
     byte[] result = Digests.DoFinal(digest, stdShaVector, 0, stdShaVector.Length);
     return(Arrays.AreEqual(result, kat));
 }
Exemplo n.º 4
0
 private BigInteger Digest(IDigest hash, byte[] input)
 {
     byte[] res = Digests.DoFinal(hash, input, 0, input.Length);
     return(new BigInteger(1, res));
 }
Exemplo n.º 5
0
 public byte[] Generate(byte[] agreed)
 {
     return(Digests.DoFinal(FipsShs.CreateDigest(digestAlg), agreed, 0, agreed.Length));
 }
 private static byte[] GetDigest(SubjectPublicKeyInfo spki)
 {
     byte[] bytes = spki.PublicKeyData.GetBytes();
     return(Digests.DoFinal(new Sha1Digest(), bytes, 0, bytes.Length));
 }
Exemplo n.º 7
0
 public byte[] Collect()
 {
     return(Digests.DoFinal(digest));
 }