Package codec.asn1

Examples of codec.asn1.ASN1OctetString


  setOID(new ASN1ObjectIdentifier(EXTENSION_OID));
  setCritical(false);

  syntax_ = new ASN1Sequence(2);
  hashAlgorithm_ = new AlgorithmIdentifier();
  certificateHash_ = new ASN1OctetString();

  syntax_.add(hashAlgorithm_);
  syntax_.add(certificateHash_);

  setValue(syntax_);
View Full Code Here


  dig = MessageDigest.getInstance(alg);
  buf = dig.digest(cert);

  syntax_ = new ASN1Sequence(2);
  hashAlgorithm_ = aid;
  certificateHash_ = new ASN1OctetString(buf);

  syntax_.add(hashAlgorithm_);
  syntax_.add(certificateHash_);

  setOID(new ASN1ObjectIdentifier(EXTENSION_OID));
View Full Code Here

  /* Key Encryption Algorithm Identifier */
  cAlg_ = new AlgorithmIdentifier();
  add(cAlg_);

  /* Encrypted Key */
  ekey_ = new ASN1OctetString();
  add(ekey_);
    }
View Full Code Here

  b = cipher.doFinal(b);

  if (b == null || b.length == 0) {
      throw new InvalidKeyException("Cipher returned no data!");
  }
  ekey_ = new ASN1OctetString(b);

  add(ekey_);
    }
View Full Code Here

  b = cipher.doFinal(b);

  if (b == null || b.length == 0) {
      throw new InvalidKeyException("Cipher returned no data!");
  }
  ekey_ = new ASN1OctetString(b);

  add(ekey_);
    }
View Full Code Here

    ASN1OctetString os_ = null;

    public DigestInfo() {
  super(2);
  aid_ = new AlgorithmIdentifier();
  os_ = new ASN1OctetString();
  add(aid_);
  add(os_);
    }
View Full Code Here

  aid_ = aid;

  add(aid);

  os_ = new ASN1OctetString();

  try {
      os_.setByteArray(digest);
  } catch (ConstraintException e) {
      System.out.println("internal error:");
View Full Code Here

                            ASN1Sequence o = (ASN1Sequence) der.readObject();

                            ASN1Sequence o1 = (ASN1Sequence) o.getObjectAt(0);

                            DERObjectIdentifier o2 = (DERObjectIdentifier) o1.getObjectAt(0);
                            ASN1OctetString o3 = (ASN1OctetString) o.getObjectAt(1);

                            byte[] actual = o3.getOctets();

                            for (int i = 0; i < actual.length; i++) {
                                if (actual[i] != hash[i]) {
                                    return false;
                                }
                            }

                        } catch (IOException ex1) {
                            throw new SSLException(SSLException.INTERNAL_ERROR, ex1.getMessage());
                        }

                    } else if (x509.getSigAlgName().equals("SHA1WithRSAEncryption")) { //$NON-NLS-1$

                        try {
                            byte[] blob = x509.getSignature();

                            // Check for signed bit
                            if ((blob[0] & 0x80) == 0x80) {
                                blob = new byte[x509.getSignature().length + 1];
                                blob[0] = 0;
                                System.arraycopy(x509.getSignature(), 0, blob, 1, x509.getSignature().length);
                            }

                            BigInteger input = new BigInteger(blob);
                            RsaPublicKey r = (RsaPublicKey) trusted.getPublicKey();

                            BigInteger decoded = Rsa.doPublic(input, r.getModulus(), r.getPublicExponent());

                            BigInteger result = Rsa.removePKCS1(decoded, 0x01);
                            byte[] sig = result.toByteArray();

                            SHA1Digest digest = new SHA1Digest();
                            digest.update(x509.getTBSCertificate(), 0, x509.getTBSCertificate().length);
                            byte[] hash = new byte[digest.getDigestSize()];
                            digest.doFinal(hash, 0);

                            DERInputStream der = new DERInputStream(new ByteArrayInputStream(sig));

                            ASN1Sequence o = (ASN1Sequence) der.readObject();

                            ASN1Sequence o1 = (ASN1Sequence) o.getObjectAt(0);

                            DERObjectIdentifier o2 = (DERObjectIdentifier) o1.getObjectAt(0);
                            ASN1OctetString o3 = (ASN1OctetString) o.getObjectAt(1);

                            byte[] actual = o3.getOctets();

                            for (int i = 0; i < actual.length; i++) {
                                if (actual[i] != hash[i]) {
                                    return false;
                                }
View Full Code Here

                DERObjectIdentifier mechanism =
                        DERObjectIdentifier.getInstance(tagged, true);
                setMechanism(mechanism.getId());
                break;
            case 2:
                ASN1OctetString mechanismToken =
                        ASN1OctetString.getInstance(tagged, true);
                setMechanismToken(mechanismToken.getOctets());
                break;
            case 3:
                ASN1OctetString mechanismListMIC =
                        ASN1OctetString.getInstance(tagged, true);
                setMechanismListMIC(mechanismListMIC.getOctets());
                break;
            default:
                throw new IOException("Malformed token field.");
            }
        }
View Full Code Here

                DERBitString contextFlags = DERBitString.getInstance(tagged,
                        true);
                setContextFlags(contextFlags.getBytes()[0] & 0xff);
                break;
            case 2:
                ASN1OctetString mechanismToken =
                        ASN1OctetString.getInstance(tagged, true);
                setMechanismToken(mechanismToken.getOctets());
                break;
            case 3:
                ASN1OctetString mechanismListMIC =
                        ASN1OctetString.getInstance(tagged, true);
                setMechanismListMIC(mechanismListMIC.getOctets());
                break;
            default:
                throw new IOException("Malformed token field.");
            }
        }
View Full Code Here

TOP

Related Classes of codec.asn1.ASN1OctetString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.