public void setStreamingPaddingScheme(PaddingScheme scheme) { setStreamingPaddingSchemeName(scheme.getTransformationName()); }
/** * Creates a new {@link DefaultBlockCipherService} using the specified block cipher {@code algorithmName}. Per this * class's JavaDoc, this constructor also sets the following defaults: * <ul> * <li>{@code streamingMode} = {@link OperationMode#CBC CBC}</li> * <li>{@code streamingPaddingScheme} = {@link PaddingScheme#NONE none}</li> * <li>{@code streamingBlockSize} = 8</li> * </ul> * All other attributes are null/unset, indicating the JCA Provider defaults will be used. * * @param algorithmName the block cipher algorithm to use when encrypting and decrypting */ public DefaultBlockCipherService(String algorithmName) { super(algorithmName); this.modeName = OperationMode.CBC.name(); this.paddingSchemeName = PaddingScheme.PKCS5.getTransformationName(); this.blockSize = DEFAULT_BLOCK_SIZE; //0 = use the JCA provider's default this.streamingModeName = OperationMode.CBC.name(); this.streamingPaddingSchemeName = PaddingScheme.PKCS5.getTransformationName(); this.streamingBlockSize = DEFAULT_STREAMING_BLOCK_SIZE; }
/** * Sets the padding scheme to be used when constructing the * {@link javax.crypto.Cipher Cipher} transformation string. A {@code null} value indicates that the JCA Provider * default padding scheme for the specified {@link #getAlgorithmName() algorithm} should be used. * <p/> * This attribute is used <em>only</em> when constructing the transformation string for block (byte array) * operations ({@link #encrypt(byte[], byte[])} and {@link #decrypt(byte[], byte[])}). The * {@link #setStreamingPaddingScheme streamingPaddingScheme} attribute is used when the block cipher is used for * streaming operations. * <p/> * If the {@link PaddingScheme PaddingScheme} enum does represent your desired scheme, you can set the name explicitly * via the {@link #setPaddingSchemeName paddingSchemeName} attribute directly. However, because * {@code PaddingScheme} represents all standard JDK scheme names already, ensure that your underlying JCA Provider * supports the non-standard name first. * * @param paddingScheme the padding scheme to be used when constructing * {@link javax.crypto.Cipher Cipher} transformation string, or {@code null} if the JCA Provider * default padding scheme for the specified {@link #getAlgorithmName() algorithm} should be used. */ public void setPaddingScheme(PaddingScheme paddingScheme) { setPaddingSchemeName(paddingScheme.getTransformationName()); }
public void setStreamingPaddingScheme(PaddingScheme scheme) { setStreamingPaddingSchemeName(scheme.getTransformationName()); }
/** * Creates a new {@link DefaultBlockCipherService} using the specified block cipher {@code algorithmName}. Per this * class's JavaDoc, this constructor also sets the following defaults: * <ul> * <li>{@code streamingMode} = {@link OperationMode#CFB CFB}</li> * <li>{@code streamingPaddingScheme} = {@link PaddingScheme#NONE none}</li> * <li>{@code streamingBlockSize} = 8</li> * </ul> * All other attributes are null/unset, indicating the JCA Provider defaults will be used. * * @param algorithmName the block cipher algorithm to use when encrypting and decrypting */ public DefaultBlockCipherService(String algorithmName) { super(algorithmName); this.modeName = OperationMode.CFB.name(); this.paddingSchemeName = PaddingScheme.PKCS5.getTransformationName(); this.blockSize = DEFAULT_BLOCK_SIZE; //0 = use the JCA provider's default this.streamingModeName = OperationMode.CFB.name(); this.streamingPaddingSchemeName = PaddingScheme.NONE.getTransformationName(); this.streamingBlockSize = DEFAULT_STREAMING_BLOCK_SIZE; }
/** * Sets the padding scheme to be used when constructing the * {@link javax.crypto.Cipher Cipher} transformation string. A {@code null} value indicates that the JCA Provider * default padding scheme for the specified {@link #getAlgorithmName() algorithm} should be used. * <p/> * This attribute is used <em>only</em> when constructing the transformation string for block (byte array) * operations ({@link #encrypt(byte[], byte[])} and {@link #decrypt(byte[], byte[])}). The * {@link #setStreamingPaddingScheme streamingPaddingScheme} attribute is used when the block cipher is used for * streaming operations. * <p/> * If the {@link PaddingScheme PaddingScheme} enum does represent your desired scheme, you can set the name explicitly * via the {@link #setPaddingSchemeName paddingSchemeName} attribute directly. However, because * {@code PaddingScheme} represents all standard JDK scheme names already, ensure that your underlying JCA Provider * supports the non-standard name first. * * @param paddingScheme the padding scheme to be used when constructing * {@link javax.crypto.Cipher Cipher} transformation string, or {@code null} if the JCA Provider * default padding scheme for the specified {@link #getAlgorithmName() algorithm} should be used. */ public void setPaddingScheme(PaddingScheme paddingScheme) { setPaddingSchemeName(paddingScheme.getTransformationName()); }