/** * The getInstance method of the PublicKey class uses this method to create * an instance of a PKCS#11 ECDSA public key. * * @param session * The session to use for reading attributes. This session must * have the appropriate rights; i.e. it must be a user-session, if * it is a private object. * @param objectHandle * The object handle as given from the PKCS#111 module. * @return The object representing the PKCS#11 object. * The returned object can be casted to the * according sub-class. * @exception TokenException * If getting the attributes failed. * @preconditions (session <> null) * @postconditions (result <> null) */ public static PKCS11Object getInstance(Session session, long objectHandle) throws TokenException { return new ECPublicKey(session, objectHandle); }
/** * 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 SM2PublicKey)) { return false; } return super.equals(otherObject); }
/** * Default Constructor. * * @preconditions * @postconditions */ public ECPublicKey() { keyType.setLongValue(thisKeyType()); }
ECPublicKey publicKey = new ECPublicKey(); setKeyAttributes(control, publicKey, privateKey); byte[] encodedCurveId; publicKey.getEcdsaParams().setByteArrayValue(encodedCurveId); return generateKeyPair(mech, control.getId(), privateKey, publicKey); } catch (P11TokenException ex) { publicKey.getEcdsaParams().setByteArrayValue(ecParams.getEncoded()); } catch (IOException ex2) { throw new P11TokenException(ex.getMessage(), ex);
byte[] encodedAlgorithmIdParameters = ecP11Key.getEcdsaParams().getByteArrayValue(); byte[] encodedPoint = DEROctetString.getInstance( ecP11Key.getEcPoint().getByteArrayValue()).getOctets(); try { return KeyUtil.createECPublicKey(encodedAlgorithmIdParameters, encodedPoint);
/** * 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); }
newObject = DSAPublicKey.getInstance(session, objectHandle); } else if (keyType.equals(Key.KeyType.EC)) { newObject = ECPublicKey.getInstance(session, objectHandle); } else if (keyType.equals(Key.KeyType.DH)) { newObject = DHPublicKey.getInstance(session, objectHandle);
/** * Called by getInstance to create an instance of a PKCS#11 ECDSA public * key. * * @param session * The session to use for reading attributes. This session must * have the appropriate rights; i.e. it must be a user-session, if * it is a private object. * @param objectHandle * The object handle as given from the PKCS#111 module. * @exception TokenException * If getting the attributes failed. * @preconditions (session <> null) * @postconditions */ protected ECPublicKey(Session session, long objectHandle) throws TokenException { super(session, objectHandle); keyType.setLongValue(thisKeyType()); }