/** * Create a generator overriding the algorithm type implied by the public key passed in. * * @param subjectKeyIdentifier the subject key identifier value to associate with the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. * @param publicKey the public key to use. */ public JceKTSKeyTransRecipientInfoGenerator(byte[] subjectKeyIdentifier, AlgorithmIdentifier algorithmIdentifier, PublicKey publicKey) { super(subjectKeyIdentifier, new JceAsymmetricKeyWrapper(algorithmIdentifier, publicKey)); }
/** * Internally algorithm ids are converted into cipher names using a lookup table. For some providers * the standard lookup table won't work. Use this method to establish a specific mapping from an * algorithm identifier to a specific algorithm. * <p> * For example: * <pre> * unwrapper.setAlgorithmMapping(PKCSObjectIdentifiers.rsaEncryption, "RSA"); * </pre> * </p> * @param algorithm OID of algorithm in recipient. * @param algorithmName JCE algorithm name to use. * @return the current RecipientInfoGenerator. */ public JceKeyTransRecipientInfoGenerator setAlgorithmMapping(ASN1ObjectIdentifier algorithm, String algorithmName) { ((JceAsymmetricKeyWrapper)this.wrapper).setAlgorithmMapping(algorithm, algorithmName); return this; } }
public JceKeyTransRecipientInfoGenerator setProvider(String providerName) { ((JceAsymmetricKeyWrapper)this.wrapper).setProvider(providerName); return this; }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException Cipher keyEncryptionCipher = helper.createAsymmetricWrapper(getAlgorithmIdentifier().getAlgorithm(), extraMappings); AlgorithmParameters algParams = helper.createAlgorithmParameters(this.getAlgorithmIdentifier());
/** * Create a wrapper, overriding the algorithm type that is stored in the public key. * * @param algorithmParameterSpec the parameterSpec for encryption algorithm to be used. * @param publicKey the public key to be used. */ public JceAsymmetricKeyWrapper(AlgorithmParameterSpec algorithmParameterSpec, PublicKey publicKey) { super(extractFromSpec(algorithmParameterSpec)); this.publicKey = publicKey; }
private static AlgorithmIdentifier extractFromSpec(AlgorithmParameterSpec algorithmParameterSpec) { if (algorithmParameterSpec instanceof OAEPParameterSpec) { OAEPParameterSpec oaepSpec = (OAEPParameterSpec)algorithmParameterSpec; if (oaepSpec.getMGFAlgorithm().equals(OAEPParameterSpec.DEFAULT.getMGFAlgorithm())) { if (oaepSpec.getPSource() instanceof PSource.PSpecified) { return new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSAES_OAEP, new RSAESOAEPparams(getDigest(oaepSpec.getDigestAlgorithm()), new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, getDigest(((MGF1ParameterSpec)oaepSpec.getMGFParameters()).getDigestAlgorithm())), new AlgorithmIdentifier(PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(((PSource.PSpecified)oaepSpec.getPSource()).getValue())))); } else { throw new IllegalArgumentException("unknown PSource: " + oaepSpec.getPSource().getAlgorithm()); } } else { throw new IllegalArgumentException("unknown MGF: " + oaepSpec.getMGFAlgorithm()); } } throw new IllegalArgumentException("unknown spec: " + algorithmParameterSpec.getClass().getName()); }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException Cipher keyEncryptionCipher = helper.createAsymmetricWrapper(getAlgorithmIdentifier().getAlgorithm(), extraMappings); AlgorithmParameters algParams = helper.createAlgorithmParameters(this.getAlgorithmIdentifier());
/** * Create a generator overriding the algorithm type implied by the public key passed in. * * @param subjectKeyIdentifier the subject key identifier value to associate with the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. * @param publicKey the public key to use. */ public JceKeyTransRecipientInfoGenerator(byte[] subjectKeyIdentifier, AlgorithmIdentifier algorithmIdentifier, PublicKey publicKey) { super(subjectKeyIdentifier, new JceAsymmetricKeyWrapper(algorithmIdentifier, publicKey)); }
public JceKeyTransRecipientInfoGenerator setProvider(Provider provider) { ((JceAsymmetricKeyWrapper)this.wrapper).setProvider(provider); return this; }
/** * Internally algorithm ids are converted into cipher names using a lookup table. For some providers * the standard lookup table won't work. Use this method to establish a specific mapping from an * algorithm identifier to a specific algorithm. * <p> * For example: * <pre> * unwrapper.setAlgorithmMapping(PKCSObjectIdentifiers.rsaEncryption, "RSA"); * </pre> * </p> * @param algorithm OID of algorithm in recipient. * @param algorithmName JCE algorithm name to use. * @return the current RecipientInfoGenerator. */ public JceKeyTransRecipientInfoGenerator setAlgorithmMapping(ASN1ObjectIdentifier algorithm, String algorithmName) { ((JceAsymmetricKeyWrapper)this.wrapper).setAlgorithmMapping(algorithm, algorithmName); return this; } }
/** * Create a generator overriding the algorithm type implied by the public key passed in. * * @param subjectKeyIdentifier the subject key identifier value to associate with the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. * @param publicKey the public key to use. */ public JceKTSKeyTransRecipientInfoGenerator(byte[] subjectKeyIdentifier, AlgorithmIdentifier algorithmIdentifier, PublicKey publicKey) { super(subjectKeyIdentifier, new JceAsymmetricKeyWrapper(algorithmIdentifier, publicKey)); }
public JceKeyTransRecipientInfoGenerator setProvider(String providerName) { ((JceAsymmetricKeyWrapper)this.wrapper).setProvider(providerName); return this; }
/** * Create a generator overriding the algorithm type implied by the public key passed in. * * @param subjectKeyIdentifier the subject key identifier value to associate with the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. * @param publicKey the public key to use. */ public JceKeyTransRecipientInfoGenerator(byte[] subjectKeyIdentifier, AlgorithmIdentifier algorithmIdentifier, PublicKey publicKey) { super(subjectKeyIdentifier, new JceAsymmetricKeyWrapper(algorithmIdentifier, publicKey)); }
public JceKeyTransRecipientInfoGenerator setProvider(Provider provider) { ((JceAsymmetricKeyWrapper)this.wrapper).setProvider(provider); return this; }
public JceKeyTransRecipientInfoGenerator(byte[] subjectKeyIdentifier, PublicKey publicKey) { super(subjectKeyIdentifier, new JceAsymmetricKeyWrapper(publicKey)); }
public JceKeyTransRecipientInfoGenerator(byte[] subjectKeyIdentifier, PublicKey publicKey) { super(subjectKeyIdentifier, new JceAsymmetricKeyWrapper(publicKey)); }
/** * Create a generator overriding the algorithm type implied by the public key in the certificate passed in. * * @param recipientCert certificate carrying the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. */ public JceKTSKeyTransRecipientInfoGenerator(X509Certificate recipientCert, AlgorithmIdentifier algorithmIdentifier) throws CertificateEncodingException { super(new IssuerAndSerialNumber(new JcaX509CertificateHolder(recipientCert).toASN1Structure()), new JceAsymmetricKeyWrapper(algorithmIdentifier, recipientCert.getPublicKey())); }
/** * Create a generator overriding the algorithm type implied by the public key in the certificate passed in. * * @param recipientCert certificate carrying the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. */ public JceKeyTransRecipientInfoGenerator(X509Certificate recipientCert, AlgorithmIdentifier algorithmIdentifier) throws CertificateEncodingException { super(new IssuerAndSerialNumber(new JcaX509CertificateHolder(recipientCert).toASN1Structure()), new JceAsymmetricKeyWrapper(algorithmIdentifier, recipientCert.getPublicKey())); }
/** * Create a generator overriding the algorithm type implied by the public key in the certificate passed in. * * @param recipientCert certificate carrying the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. */ public JceKTSKeyTransRecipientInfoGenerator(X509Certificate recipientCert, AlgorithmIdentifier algorithmIdentifier) throws CertificateEncodingException { super(new IssuerAndSerialNumber(new JcaX509CertificateHolder(recipientCert).toASN1Structure()), new JceAsymmetricKeyWrapper(algorithmIdentifier, recipientCert.getPublicKey())); }
/** * Create a generator overriding the algorithm type implied by the public key in the certificate passed in. * * @param recipientCert certificate carrying the public key. * @param algorithmIdentifier the identifier and parameters for the encryption algorithm to be used. */ public JceKeyTransRecipientInfoGenerator(X509Certificate recipientCert, AlgorithmIdentifier algorithmIdentifier) throws CertificateEncodingException { super(new IssuerAndSerialNumber(new JcaX509CertificateHolder(recipientCert).toASN1Structure()), new JceAsymmetricKeyWrapper(algorithmIdentifier, recipientCert.getPublicKey())); }