private PublicKey getPublicKeyObject(Session session, byte[] keyId, char[] keyLabel) throws P11TokenException { return (PublicKey) getKeyObject(session, new PublicKey(), keyId, keyLabel); }
/** * Allocates the attribute objects for this class and adds them to the * attribute table. * * @preconditions * @postconditions */ @Override protected void allocateAttributes() { super.allocateAttributes(); ecdsaParams = new ByteArrayAttribute(Attribute.EC_PARAMS); ecPoint = new ByteArrayAttribute(Attribute.EC_POINT); putAttributesInTable(this); }
/** * Compares all member variables of this object with the other object. * Returns only true, if all are equal in both objects. * * @param otherObject * The other object to compare to. * @return True, if other is an instance of this class and all member * variables of both objects are equal. False, otherwise. * @preconditions * @postconditions */ @Override public boolean equals(Object otherObject) { if (this == otherObject) { return true; } if (!(otherObject instanceof KeyPair)) { return false; } KeyPair other = (KeyPair) otherObject; return this.publicKey.equals(other.publicKey) && this.privateKey.equals(other.privateKey); }
getAttributeValue(session, objectHandle, keyTypeAttribute); } else if ((keyType.longValue() & KeyType.VENDOR_DEFINED.longValue()) != 0L) { newObject = getUnknownPublicKey(session, objectHandle); } else { newObject = getUnknownPublicKey(session, objectHandle); newObject = getUnknownPublicKey(session, objectHandle);
private static void setKeyAttributes(final String label, final long keyType, final P11NewKeyControl control, final PublicKey publicKey, final PrivateKey privateKey) { if (privateKey != null) { privateKey.getToken().setBooleanValue(true); privateKey.getLabel().setCharArrayValue(label.toCharArray()); privateKey.getKeyType().setLongValue(keyType); privateKey.getSign().setBooleanValue(true); privateKey.getPrivate().setBooleanValue(true); privateKey.getSensitive().setBooleanValue(true); privateKey.getExtractable().setBooleanValue(control.isExtractable()); } if (publicKey != null) { publicKey.getToken().setBooleanValue(true); publicKey.getLabel().setCharArrayValue(label.toCharArray()); publicKey.getKeyType().setLongValue(keyType); publicKey.getVerify().setBooleanValue(true); publicKey.getModifiable().setBooleanValue(Boolean.TRUE); } }
private void analyseSingleKey(Session session, PrivateKey privKey, P11SlotRefreshResult refreshResult) throws P11TokenException, XiSecurityException { byte[] id = privKey.getId().getByteArrayValue(); char[] label = privKey.getLabel().getCharArrayValue(); if (id == null || label == null) { return; } String pubKeyLabel = null; PublicKey p11PublicKey = getPublicKeyObject(session, id, null); if (p11PublicKey != null) { pubKeyLabel = new String(p11PublicKey.getLabel().getCharArrayValue()); } String certLabel = null; java.security.PublicKey pubKey = null; X509Cert cert = refreshResult.getCertForId(id); if (cert != null) { certLabel = refreshResult.getCertLabelForId(id); pubKey = cert.getCert().getPublicKey(); } else if (p11PublicKey != null) { pubKey = generatePublicKey(p11PublicKey); } else { LOG.info("neither certificate nor public key for the key (" + hex(id) + " is available"); return; } P11ObjectIdentifier objectId = new P11ObjectIdentifier(id, new String(label)); X509Certificate[] certs = (cert == null) ? null : new X509Certificate[]{cert.getCert()}; IaikP11Identity identity = new IaikP11Identity(this, new P11IdentityId(slotId, objectId, pubKeyLabel, certLabel), privKey, pubKey, certs); refreshResult.addIdentity(identity); }
publicKey.getId().setByteArrayValue(id); try { keypair = session.generateKeyPair(Mechanism.get(mech), publicKey, privateKey);
newObject = PrivateKey.getInstance(session, objectHandle); } else if (objectClass.equals(ObjectClass.PUBLIC_KEY)) { newObject = PublicKey.getInstance(session, objectHandle); } else if (objectClass.equals(ObjectClass.CERTIFICATE)) { newObject = Certificate.getInstance(session, objectHandle);
private PublicKey getPublicKeyObject(final byte[] keyId, final char[] keyLabel) throws P11TokenException { return (PublicKey) getKeyObject(new PublicKey(), keyId, keyLabel); }
/** * Compares all member variables of this object with the other object. * Returns only true, if all are equal in both objects. * * @param otherObject * The other object to compare to. * @return True, if other is an instance of this class and all member * variables of both objects are equal. False, otherwise. * @preconditions * @postconditions */ @Override public boolean equals(Object otherObject) { if (this == otherObject) { return true; } else if (!(otherObject instanceof ECPublicKey)) { return false; } ECPublicKey other = (ECPublicKey) otherObject; return super.equals(other) && this.ecdsaParams.equals(other.ecdsaParams) && this.ecPoint.equals(other.ecPoint); }
/** * Allocates the attribute objects for this class and adds them to the * attribute table. * * @preconditions * @postconditions */ @Override protected void allocateAttributes() { super.allocateAttributes(); modulus = new ByteArrayAttribute(Attribute.MODULUS); publicExponent = new ByteArrayAttribute(Attribute.PUBLIC_EXPONENT); modulusBits = new LongAttribute(Attribute.MODULUS_BITS); putAttributesInTable(this); }
/** * Compares all member variables of this object with the other object. * Returns only true, if all are equal in both objects. * * @param otherObject * The other object to compare to. * @return True, if other is an instance of this class and all member * variables of both objects are equal. False, otherwise. * @preconditions * @postconditions */ @Override public boolean equals(Object otherObject) { if (this == otherObject) { return true; } else if (!(otherObject instanceof RSAPublicKey)) { return false; } RSAPublicKey other = (RSAPublicKey) otherObject; return super.equals(other) && this.modulus.equals(other.modulus) && this.publicExponent.equals(other.publicExponent) && this.modulusBits.equals(other.modulusBits); }
/** * Allocates the attribute objects for this class and adds them to the * attribute table. * * @preconditions * @postconditions */ @Override protected void allocateAttributes() { super.allocateAttributes(); prime = new ByteArrayAttribute(Attribute.PRIME); base = new ByteArrayAttribute(Attribute.BASE); value = new ByteArrayAttribute(Attribute.VALUE); putAttributesInTable(this); }
/** * Compares all member variables of this object with the other object. * Returns only true, if all are equal in both objects. * * @param otherObject * The other object to compare to. * @return True, if other is an instance of this class and all member * variables of both objects are equal. False, otherwise. * @preconditions * @postconditions */ @Override public boolean equals(Object otherObject) { if (this == otherObject) { return true; } else if (!(otherObject instanceof DHPublicKey)) { return false; } DHPublicKey other = (DHPublicKey) otherObject; return super.equals(other) && this.prime.equals(other.prime) && this.base.equals(other.base) && this.value.equals(other.value); }
/** * Allocates the attribute objects for this class and adds them to the * attribute table. * * @preconditions * @postconditions */ @Override protected void allocateAttributes() { super.allocateAttributes(); prime = new ByteArrayAttribute(Attribute.PRIME); subprime = new ByteArrayAttribute(Attribute.SUBPRIME); base = new ByteArrayAttribute(Attribute.BASE); value = new ByteArrayAttribute(Attribute.VALUE); putAttributesInTable(this); }
/** * Compares all member variables of this object with the other object. * Returns only true, if all are equal in both objects. * * @param otherObject * The other object to compare to. * @return True, if other is an instance of this class and all member * variables of both objects are equal. False, otherwise. * @preconditions * @postconditions */ @Override public boolean equals(Object otherObject) { if (this == otherObject) { return true; } else if (!(otherObject instanceof DSAPublicKey)) { return false; } DSAPublicKey other = (DSAPublicKey) otherObject; return super.equals(other) && this.prime.equals(other.prime) && this.subprime.equals(other.subprime) && this.base.equals(other.base) && this.value.equals(other.value); }
/** * Allocates the attribute objects for this class and adds them to the * attribute table. * * @preconditions * @postconditions */ @Override protected void allocateAttributes() { super.allocateAttributes(); prime = new ByteArrayAttribute(Attribute.PRIME); subprime = new ByteArrayAttribute(Attribute.SUBPRIME); base = new ByteArrayAttribute(Attribute.BASE); value = new ByteArrayAttribute(Attribute.VALUE); putAttributesInTable(this); }