@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); }
DSAPublicKey dsaP11Key = (DSAPublicKey) p11Key; BigInteger prime = new BigInteger(1, dsaP11Key.getPrime().getByteArrayValue()); // p BigInteger subPrime = new BigInteger(1, dsaP11Key.getSubprime().getByteArrayValue()); // q BigInteger base = new BigInteger(1, dsaP11Key.getBase().getByteArrayValue()); // g BigInteger value = new BigInteger(1, dsaP11Key.getValue().getByteArrayValue()); // y DSAPublicKeySpec keySpec = new DSAPublicKeySpec(value, prime, subPrime, base); try {
/** * The getInstance method of the PublicKey class uses this method to create * an instance of a PKCS#11 DSA 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 DSAPublicKey(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 = RSAPublicKey.getInstance(session, objectHandle); } else if (keyType.equals(Key.KeyType.DSA)) { newObject = DSAPublicKey.getInstance(session, objectHandle); } else if (keyType.equals(Key.KeyType.EC)) { newObject = ECPublicKey.getInstance(session, objectHandle);
DSAPublicKey dsaP11Key = (DSAPublicKey) p11Key; BigInteger prime = new BigInteger(1, dsaP11Key.getPrime().getByteArrayValue()); // p BigInteger subPrime = new BigInteger(1, dsaP11Key.getSubprime().getByteArrayValue()); // q BigInteger base = new BigInteger(1, dsaP11Key.getBase().getByteArrayValue()); // g BigInteger value = new BigInteger(1, dsaP11Key.getValue().getByteArrayValue()); // y DSAPublicKeySpec keySpec = new DSAPublicKeySpec(value, prime, subPrime, base); try {
@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); }