本文整理了Java中javax.crypto.BadPaddingException.<init>()
方法的一些代码示例,展示了BadPaddingException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BadPaddingException.<init>()
方法的具体详情如下:
包路径:javax.crypto.BadPaddingException
类名称:BadPaddingException
方法名:<init>
[英]Creates a new instance of BadPaddingException with no message.
[中]创建没有消息的BadPaddingException的新实例。
代码示例来源:origin: wildfly/wildfly
private byte[] pkcs7UnPad(byte[] buffer) throws BadPaddingException {
byte last = buffer[buffer.length - 1];
int i = buffer.length - 2;
while (buffer[i] == last) {
i--;
}
if (i + 1 + last != buffer.length) {
throw new BadPaddingException();
}
return Arrays.copyOfRange(buffer, 0, i + 1);
}
代码示例来源:origin: i2p/i2p.i2p
/**
* Throws an instance of AEADBadTagException.
*
* @throws BadPaddingException The AEAD exception.
*
* If the underlying JDK does not have the AEADBadTagException
* class, then this function will instead throw an instance of
* the superclass BadPaddingException.
*/
static void throwBadTagException() throws BadPaddingException
{
try {
// java since 1.7; android since API 19
Class<?> c = Class.forName("javax.crypto.AEADBadTagException");
throw (BadPaddingException)(c.getDeclaredConstructor().newInstance());
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (NoSuchMethodException e) {
}
throw new BadPaddingException();
}
}
代码示例来源:origin: martinpaljak/GlobalPlatformPro
public static byte[] unpad80(byte[] text) throws BadPaddingException {
if (text.length < 1)
throw new BadPaddingException("Invalid ISO 7816-4 padding");
int offset = text.length - 1;
while (offset > 0 && text[offset] == 0) {
offset--;
}
if (text[offset] != (byte) 0x80) {
throw new BadPaddingException("Invalid ISO 7816-4 padding");
}
return Arrays.copyOf(text, offset);
}
代码示例来源:origin: org.wildfly.security/wildfly-elytron
private byte[] pkcs7UnPad(byte[] buffer) throws BadPaddingException {
byte last = buffer[buffer.length - 1];
int i = buffer.length - 2;
while (buffer[i] == last) {
i--;
}
if (i + 1 + last != buffer.length) {
throw new BadPaddingException();
}
return Arrays.copyOfRange(buffer, 0, i + 1);
}
代码示例来源:origin: org.wildfly.security/wildfly-elytron-credential-store
private byte[] pkcs7UnPad(byte[] buffer) throws BadPaddingException {
byte last = buffer[buffer.length - 1];
int i = buffer.length - 2;
while (buffer[i] == last) {
i--;
}
if (i + 1 + last != buffer.length) {
throw new BadPaddingException();
}
return Arrays.copyOfRange(buffer, 0, i + 1);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private byte[] pkcs7UnPad(byte[] buffer) throws BadPaddingException {
byte last = buffer[buffer.length - 1];
int i = buffer.length - 2;
while (buffer[i] == last) {
i--;
}
if (i + 1 + last != buffer.length) {
throw new BadPaddingException();
}
return Arrays.copyOfRange(buffer, 0, i + 1);
}
代码示例来源:origin: i2p/i2p.i2p
throw new BadPaddingException("Null remote public key");
代码示例来源:origin: stackoverflow.com
private static final String SHA1_PAD = "3021300906052b0e03021a05000414";
private static final byte[] sha1pad = DatatypeConverter.parseHexBinary(SHA1_PAD);
public static byte[] unpadSHA1(byte[] padded) throws BadPaddingException {
int k = 0;
if (padded.length < sha1pad.length) {
throw new BadPaddingException("Padding string too short");
}
while (true) {
if (padded[k] != sha1pad[k]) {
break;
}
k++;
if (k == sha1pad.length) {
break;
}
}
int n = padded.length - k;
if (n > 256) {
throw new BadPaddingException("Padding string too short");
}
byte[] data = new byte[n];
System.arraycopy(padded, padded.length - n, data, 0, n);
return data;
}
代码示例来源:origin: cloudfoundry-incubator/credhub
@Override
public String decrypt(final Key key, final byte[] encryptedValue, final byte[] nonce)
throws Exception {
throw new BadPaddingException("");
}
});
代码示例来源:origin: com.madgag.spongycastle/prov
public int doFinal(byte[] out, int outOff) throws IllegalStateException, BadPaddingException
{
try
{
return cipher.doFinal(out, outOff);
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
public int doFinal(byte[] out, int outOff) throws IllegalStateException, BadPaddingException
{
try
{
return cipher.doFinal(out, outOff);
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
public byte[] engineDoFinal(
byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException, BadPaddingException
{
if (inputLen != 0)
{
buffer.write(input, inputOffset, inputLen);
}
try
{
byte[] buf = buffer.toByteArray();
buffer.reset();
return cipher.processBlock(buf, 0, buf.length);
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: ripple-unmaintained/ripple-lib-java
public int doFinal(byte[] out, int outOff) throws IllegalStateException, BadPaddingException
{
try
{
return cipher.doFinal(out, outOff);
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
}
代码示例来源:origin: ripple-unmaintained/ripple-lib-java
protected byte[] engineDoFinal(
byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException, BadPaddingException
{
if (inputLen != 0)
{
buffer.write(input, inputOffset, inputLen);
}
try
{
byte[] buf = buffer.toByteArray();
buffer.reset();
return cipher.processBlock(buf, 0, buf.length);
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: com.madgag/scprov-jdk15on
protected byte[] engineDoFinal(
byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException, BadPaddingException
{
if (inputLen != 0)
{
buffer.write(input, inputOffset, inputLen);
}
try
{
byte[] buf = buffer.toByteArray();
buffer.reset();
return cipher.processBlock(buf, 0, buf.length);
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
public int engineDoFinal(
byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws IllegalBlockSizeException, BadPaddingException
{
if (inputLen != 0)
{
buffer.write(input, inputOffset, inputLen);
}
try
{
byte[] buf = buffer.toByteArray();
buffer.reset();
buf = cipher.processBlock(buf, 0, buf.length);
System.arraycopy(buf, 0, output, outputOffset, buf.length);
return buf.length;
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: com.madgag/scprov-jdk15on
protected byte[] engineDoFinal(
byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException, BadPaddingException
{
cipher.processBytes(input, inputOffset, inputLen);
try
{
return cipher.doFinal();
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: ripple-unmaintained/ripple-lib-java
protected byte[] engineDoFinal(
byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException, BadPaddingException
{
cipher.processBytes(input, inputOffset, inputLen);
try
{
return cipher.doFinal();
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: com.madgag.spongycastle/prov
protected int engineDoFinal(
byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws IllegalBlockSizeException, BadPaddingException
{
int len = 0;
if (inputLen != 0)
{
len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset);
}
try
{
return len + cipher.doFinal(output, outputOffset + len);
}
catch (DataLengthException e)
{
throw new IllegalBlockSizeException(e.getMessage());
}
catch (InvalidCipherTextException e)
{
throw new BadPaddingException(e.getMessage());
}
}
代码示例来源:origin: Microsoft/AppCenter-SDK-Android
@Test
public void failsToEncrypt() throws Exception {
CryptoUtils cryptoUtils = new CryptoUtils(mContext, mCryptoFactory, Build.VERSION_CODES.KITKAT);
when(mCipher.doFinal(any(byte[].class))).thenThrow(new BadPaddingException());
String data = "anythingThatWouldMakeTheCipherFailForSomeReason";
String encryptedData = cryptoUtils.encrypt(data);
assertEquals(data, encryptedData);
CryptoUtils.DecryptedData decryptedData = cryptoUtils.decrypt(encryptedData, false);
assertEquals(data, decryptedData.getDecryptedData());
assertNull(decryptedData.getNewEncryptedData());
decryptedData = cryptoUtils.decrypt(encryptedData, true);
assertEquals(data, decryptedData.getDecryptedData());
assertNull(decryptedData.getNewEncryptedData());
}
内容来源于网络,如有侵权,请联系作者删除!