/** * The getInstance method of the PrivateKey class uses this method to create * an instance of a PKCS#11 DSA private 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 DSAPrivateKey(session, objectHandle); }
/** * 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); }
newObject = RSAPrivateKey.getInstance(session, objectHandle); } else if (keyType.equals(Key.KeyType.DSA)) { newObject = DSAPrivateKey.getInstance(session, objectHandle); } else if (keyType.equals(Key.KeyType.EC)) { newObject = ECPrivateKey.getInstance(session, objectHandle);
@Override // CHECKSTYLE:OFF protected P11Identity generateDSAKeypair0(final BigInteger p, final BigInteger q, final BigInteger g, final String label, P11NewKeyControl control) throws P11TokenException { // CHECKSTYLE:ON DSAPrivateKey privateKey = new DSAPrivateKey(); DSAPublicKey publicKey = new DSAPublicKey(); setKeyAttributes(label, PKCS11Constants.CKK_DSA, control, publicKey, privateKey); publicKey.getPrime().setByteArrayValue(p.toByteArray()); publicKey.getSubprime().setByteArrayValue(q.toByteArray()); publicKey.getBase().setByteArrayValue(g.toByteArray()); return generateKeyPair(PKCS11Constants.CKM_DSA_KEY_PAIR_GEN, privateKey, publicKey); }
@Override // CHECKSTYLE:SKIP protected P11Identity generateDSAKeypair0(BigInteger p, BigInteger q, BigInteger g, P11NewKeyControl control) throws P11TokenException { long mech = PKCS11Constants.CKM_DSA_KEY_PAIR_GEN; assertMechanismSupported(mech); DSAPrivateKey privateKey = new DSAPrivateKey(); DSAPublicKey publicKey = new DSAPublicKey(); setKeyAttributes(control, publicKey, privateKey); publicKey.getPrime().setByteArrayValue(p.toByteArray()); publicKey.getSubprime().setByteArrayValue(q.toByteArray()); publicKey.getBase().setByteArrayValue(g.toByteArray()); return generateKeyPair(mech, control.getId(), privateKey, publicKey); }