public static PKMACValue getInstance(Object o) { if (o instanceof PKMACValue) { return (PKMACValue)o; } if (o != null) { return new PKMACValue(ASN1Sequence.getInstance(o)); } return null; }
public static PKMACValue getInstance(ASN1TaggedObject obj, boolean isExplicit) { return getInstance(ASN1Sequence.getInstance(obj, isExplicit)); }
public boolean isValid(PKMACValue value, char[] password, SubjectPublicKeyInfo keyInfo) throws CRMFException { builder.setParameters(PBMParameter.getInstance(value.getAlgId().getParameters())); MacCalculator calculator = builder.build(password); OutputStream macOut = calculator.getOutputStream(); try { macOut.write(keyInfo.getEncoded(ASN1Encoding.DER)); macOut.close(); } catch (IOException e) { throw new CRMFException("exception encoding mac input: " + e.getMessage(), e); } return Arrays.areEqual(calculator.getMac(), value.getValue().getBytes()); } }
public boolean isValid(PKMACValue value, char[] password, SubjectPublicKeyInfo keyInfo) throws CRMFException { builder.setParameters(PBMParameter.getInstance(value.getAlgId().getParameters())); MacCalculator calculator = builder.build(password); OutputStream macOut = calculator.getOutputStream(); try { macOut.write(keyInfo.getEncoded(ASN1Encoding.DER)); macOut.close(); } catch (IOException e) { throw new CRMFException("exception encoding mac input: " + e.getMessage(), e); } return Arrays.areEqual(calculator.getMac(), value.getValue().getBytes()); } }
public static PKMACValue getInstance(Object o) { if (o instanceof PKMACValue) { return (PKMACValue)o; } if (o != null) { return new PKMACValue(ASN1Sequence.getInstance(o)); } return null; }
public static PKMACValue getInstance(ASN1TaggedObject obj, boolean isExplicit) { return getInstance(ASN1Sequence.getInstance(obj, isExplicit)); }
public PKMACValue generate(char[] password, SubjectPublicKeyInfo keyInfo) throws CRMFException { MacCalculator calculator = builder.build(password); OutputStream macOut = calculator.getOutputStream(); try { macOut.write(keyInfo.getEncoded(ASN1Encoding.DER)); macOut.close(); } catch (IOException e) { throw new CRMFException("exception encoding mac input: " + e.getMessage(), e); } return new PKMACValue(calculator.getAlgorithmIdentifier(), new DERBitString(calculator.getMac())); } }
private POPOPrivKey(ASN1TaggedObject obj) { this.tagNo = obj.getTagNo(); switch (tagNo) { case thisMessage: this.obj = DERBitString.getInstance(obj, false); break; case subsequentMessage: this.obj = SubsequentMessage.valueOf(ASN1Integer.getInstance(obj, false).getValue().intValue()); break; case dhMAC: this.obj = DERBitString.getInstance(obj, false); break; case agreeMAC: this.obj = PKMACValue.getInstance(obj, false); break; case encryptedKey: this.obj = EnvelopedData.getInstance(obj, false); break; default: throw new IllegalArgumentException("unknown tag in POPOPrivKey"); } }
public PKMACValue generate(char[] password, SubjectPublicKeyInfo keyInfo) throws CRMFException { MacCalculator calculator = builder.build(password); OutputStream macOut = calculator.getOutputStream(); try { macOut.write(keyInfo.getEncoded(ASN1Encoding.DER)); macOut.close(); } catch (IOException e) { throw new CRMFException("exception encoding mac input: " + e.getMessage(), e); } return new PKMACValue(calculator.getAlgorithmIdentifier(), new DERBitString(calculator.getMac())); } }
private POPOPrivKey(ASN1TaggedObject obj) { this.tagNo = obj.getTagNo(); switch (tagNo) { case thisMessage: this.obj = DERBitString.getInstance(obj, false); break; case subsequentMessage: this.obj = SubsequentMessage.valueOf(ASN1Integer.getInstance(obj, false).getValue().intValue()); break; case dhMAC: this.obj = DERBitString.getInstance(obj, false); break; case agreeMAC: this.obj = PKMACValue.getInstance(obj, false); break; case encryptedKey: this.obj = EnvelopedData.getInstance(obj, false); break; default: throw new IllegalArgumentException("unknown tag in POPOPrivKey"); } }
private POPOSigningKeyInput(ASN1Sequence seq) { ASN1Encodable authInfo = (ASN1Encodable)seq.getObjectAt(0); if (authInfo instanceof ASN1TaggedObject) { ASN1TaggedObject tagObj = (ASN1TaggedObject)authInfo; if (tagObj.getTagNo() != 0) { throw new IllegalArgumentException( "Unknown authInfo tag: " + tagObj.getTagNo()); } sender = GeneralName.getInstance(tagObj.getObject()); } else { publicKeyMAC = PKMACValue.getInstance(authInfo); } publicKey = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(1)); }
private POPOSigningKeyInput(ASN1Sequence seq) { ASN1Encodable authInfo = (ASN1Encodable)seq.getObjectAt(0); if (authInfo instanceof ASN1TaggedObject) { ASN1TaggedObject tagObj = (ASN1TaggedObject)authInfo; if (tagObj.getTagNo() != 0) { throw new IllegalArgumentException( "Unknown authInfo tag: " + tagObj.getTagNo()); } sender = GeneralName.getInstance(tagObj.getObject()); } else { publicKeyMAC = PKMACValue.getInstance(authInfo); } publicKey = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(1)); }