当前位置: 首页>>代码示例>>Java>>正文


Java ISO7816d4Padding类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.paddings.ISO7816d4Padding的典型用法代码示例。如果您正苦于以下问题:Java ISO7816d4Padding类的具体用法?Java ISO7816d4Padding怎么用?Java ISO7816d4Padding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ISO7816d4Padding类属于org.bouncycastle.crypto.paddings包,在下文中一共展示了ISO7816d4Padding类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initCiphers

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
private void initCiphers(byte[] key, byte[] iv) {

		// get the keyBytes
		keyBytes = new byte[key.length];
		System.arraycopy(key, 0, keyBytes, 0, key.length);

		keyP = new KeyParameter(keyBytes);

		// get the IV
		IV = new byte[blockSize];
		System.arraycopy(iv, 0, IV, 0, IV.length);

		// create the ciphers
		// AES block cipher in CBC mode with ISO7816d4 padding
		encryptCipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(
				new AESFastEngine()), new ISO7816d4Padding());

		decryptCipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(
				new AESFastEngine()), new ISO7816d4Padding());

		// create the IV parameter
		ParametersWithIV parameterIV = new ParametersWithIV(keyP, IV);

		encryptCipher.init(true, parameterIV);
		decryptCipher.init(false, parameterIV);
	}
 
开发者ID:tsenger,项目名称:animamea,代码行数:27,代码来源:AmAESCrypto.java

示例2: initCiphers

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
private void initCiphers(byte[] key, byte[] iv) {
	// get the keyBytes
	keyBytes = new byte[key.length];
	System.arraycopy(key, 0, keyBytes, 0, key.length);

	// get the IV
	IV = new byte[blockSize];
	System.arraycopy(iv, 0, IV, 0, iv.length);

	keyP = new KeyParameter(keyBytes);

	encryptCipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(
			new DESedeEngine()), new ISO7816d4Padding());
	decryptCipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(
			new DESedeEngine()), new ISO7816d4Padding());

	// create the IV parameter
	ParametersWithIV parameterIV = new ParametersWithIV(keyP, IV);

	encryptCipher.init(true, parameterIV);
	decryptCipher.init(false, parameterIV);
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:23,代码来源:AmDESCrypto.java

示例3: doFinal

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
public int doFinal(byte[] out, int outOff)
{
    int blockSize = cipher.getBlockSize();

    byte[] lu;
    if (bufOff == blockSize)
    {
        lu = Lu;
    }
    else
    {
        new ISO7816d4Padding().addPadding(buf, bufOff);
        lu = Lu2;
    }

    for (int i = 0; i < mac.length; i++)
    {
        buf[i] ^= lu[i];
    }

    cipher.processBlock(buf, 0, mac, 0);

    System.arraycopy(mac, 0, out, outOff, macSize);

    reset();

    return macSize;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:CMac.java

示例4: initBlockCipherPaddings

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
private static void initBlockCipherPaddings() {
	blockCipherPadding.put("ISO10126d2Padding", ISO10126d2Padding.class);
	blockCipherPadding.put("ISO7816d4Padding", ISO7816d4Padding.class);
	blockCipherPadding.put("PKCS7Padding", PKCS7Padding.class);
	blockCipherPadding.put("TBCPadding", TBCPadding.class);
	blockCipherPadding.put("X923Padding", X923Padding.class);
	blockCipherPadding.put("ZeroBytePadding", ZeroBytePadding.class);
}
 
开发者ID:shilongdai,项目名称:vsDiaryWriter,代码行数:9,代码来源:BlockCiphers.java

示例5: getMAC

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
@Override
public byte[] getMAC(byte[] key, byte[] data) {
	BlockCipher cipher = new DESEngine();
	Mac mac = new ISO9797Alg3Mac(cipher, 64, new ISO7816d4Padding());

	KeyParameter keyP = new KeyParameter(key);
	mac.init(keyP);
	mac.update(data, 0, data.length);

	byte[] out = new byte[8];

	mac.doFinal(out, 0);

	return out;
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:16,代码来源:AmDESCrypto.java

示例6: addPadding

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
/**
 * Diese Methode füllt ein Byte-Array mit dem Wert 0x80 und mehreren 0x00
 * bis die Länge des übergebenen Byte-Array ein Vielfaches der Blocklänge
 * ist. Dies ist die ISO9797-1 Padding-Methode 2 bzw. ISO7816d4-Padding
 * 
 * @param data
 *            Das Byte-Array welches aufgefüllt werden soll.
 * @return Das gefüllte Byte-Array.
 */
public byte[] addPadding(byte[] data) {

	int len = data.length;
	int nLen = ((len / getBlockSize()) + 1) * getBlockSize();
	byte[] n = new byte[nLen];
	System.arraycopy(data, 0, n, 0, data.length);
	new ISO7816d4Padding().addPadding(n, len);
	return n;
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:19,代码来源:AmCryptoProvider.java

示例7: DES64with7816d4

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
public DES64with7816d4()
{
    super(new CBCBlockCipherMac(new DESEngine(), 64, new ISO7816d4Padding()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DES.java

示例8: DES9797Alg3with7816d4

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
public DES9797Alg3with7816d4()
{
    super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DES.java

示例9: DESede64with7816d4

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
public DESede64with7816d4()
{
    super(new CBCBlockCipherMac(new DESedeEngine(), 64, new ISO7816d4Padding()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DESede.java

示例10: engineSetPadding

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
protected void engineSetPadding(
    String  padding)
throws NoSuchPaddingException
{
    String  paddingName = Strings.toUpperCase(padding);

    if (paddingName.equals("NOPADDING"))
    {
        if (cipher.wrapOnNoPadding())
        {
            cipher = new BufferedGenericBlockCipher(new BufferedBlockCipher(cipher.getUnderlyingCipher()));
        }
    }
    else if (paddingName.equals("WITHCTS"))
    {
        cipher = new BufferedGenericBlockCipher(new CTSBlockCipher(cipher.getUnderlyingCipher()));
    }
    else
    {
        padded = true;

        if (isAEADModeName(modeName))
        {
            throw new NoSuchPaddingException("Only NoPadding can be used with AEAD modes.");
        }
        else if (paddingName.equals("PKCS5PADDING") || paddingName.equals("PKCS7PADDING"))
        {
            cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher());
        }
        else if (paddingName.equals("ZEROBYTEPADDING"))
        {
            cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ZeroBytePadding());
        }
        else if (paddingName.equals("ISO10126PADDING") || paddingName.equals("ISO10126-2PADDING"))
        {
            cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ISO10126d2Padding());
        }
        else if (paddingName.equals("X9.23PADDING") || paddingName.equals("X923PADDING"))
        {
            cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new X923Padding());
        }
        else if (paddingName.equals("ISO7816-4PADDING") || paddingName.equals("ISO9797-1PADDING"))
        {
            cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ISO7816d4Padding());
        }
        else if (paddingName.equals("TBCPADDING"))
        {
            cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new TBCPadding());
        }
        else
        {
            throw new NoSuchPaddingException("Padding " + padding + " unknown.");
        }
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:56,代码来源:BaseBlockCipher.java

示例11: performTest

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
public void performTest()
{
    SecureRandom    rand = new SecureRandom(new byte[20]);
    
    rand.setSeed(System.currentTimeMillis());
    
    testPadding(new PKCS7Padding(), rand,
                                Hex.decode("ffffff0505050505"),
                                Hex.decode("0000000004040404"));

    PKCS7Padding padder = new PKCS7Padding();
    try
    {
        padder.padCount(new byte[8]);

        fail("invalid padding not detected");
    }
    catch (InvalidCipherTextException e)
    {
        if (!"pad block corrupted".equals(e.getMessage()))
        {
            fail("wrong exception for corrupt padding: " + e);
        }
    } 

    testPadding(new ISO10126d2Padding(), rand,
                                null,
                                null);
    
    testPadding(new X923Padding(), rand,
                                null,
                                null);

    testPadding(new TBCPadding(), rand,
                                Hex.decode("ffffff0000000000"),
                                Hex.decode("00000000ffffffff"));

    testPadding(new ZeroBytePadding(), rand,
                                Hex.decode("ffffff0000000000"),
                                null);
    
    testPadding(new ISO7816d4Padding(), rand,
                                Hex.decode("ffffff8000000000"),
                                Hex.decode("0000000080000000"));

    testOutputSizes();

}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:49,代码来源:PaddingTest.java

示例12: pad

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
private static byte[] pad(byte[] in) {
	final byte[] result = Arrays.copyOf(in, 16);
	new ISO7816d4Padding().addPadding(result, in.length);
	return result;
}
 
开发者ID:cryptomator,项目名称:siv-mode,代码行数:6,代码来源:SivMode.java

示例13: _createMACCalculator

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
@Override
public MACCalculator _createMACCalculator() {
	final BlockCipher cipher = new DESEngine();
	return new MACCalculatorImpl(new ISO9797Alg3Mac(cipher, new ISO7816d4Padding()), 24, cipher.getBlockSize());
}
 
开发者ID:subshare,项目名称:subshare,代码行数:6,代码来源:MACCalculatorFactoryImpl.java

示例14: performTest

import org.bouncycastle.crypto.paddings.ISO7816d4Padding; //导入依赖的package包/类
public void performTest()
{
    SecureRandom    rand = new SecureRandom(new byte[20]);
    
    rand.setSeed(System.currentTimeMillis());
    
    testPadding(new PKCS7Padding(), rand,
                                Hex.decode("ffffff0505050505"),
                                Hex.decode("0000000004040404"));

    PKCS7Padding padder = new PKCS7Padding();
    try
    {
        padder.padCount(new byte[8]);

        fail("invalid padding not detected");
    }
    catch (InvalidCipherTextException e)
    {
        if (!"pad block corrupted".equals(e.getMessage()))
        {
            fail("wrong exception for corrupt padding: " + e);
        }
    } 

    testPadding(new ISO10126d2Padding(), rand,
                                null,
                                null);
    
    testPadding(new X923Padding(), rand,
                                null,
                                null);

    testPadding(new TBCPadding(), rand,
                                Hex.decode("ffffff0000000000"),
                                Hex.decode("00000000ffffffff"));

    testPadding(new ZeroBytePadding(), rand,
                                Hex.decode("ffffff0000000000"),
                                null);
    
    testPadding(new ISO7816d4Padding(), rand,
                                Hex.decode("ffffff8000000000"),
                                Hex.decode("0000000080000000"));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:46,代码来源:PaddingTest.java


注:本文中的org.bouncycastle.crypto.paddings.ISO7816d4Padding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。