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


Java ShortBufferException.printStackTrace方法代码示例

本文整理汇总了Java中javax.crypto.ShortBufferException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ShortBufferException.printStackTrace方法的具体用法?Java ShortBufferException.printStackTrace怎么用?Java ShortBufferException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.crypto.ShortBufferException的用法示例。


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

示例1: generateSecret

import javax.crypto.ShortBufferException; //导入方法依赖的package包/类
public byte[] generateSecret() throws IllegalStateException {
    byte[] sharedSecret = new byte[KEY_SIZE];
    try {
        generateSecret(sharedSecret, 0);
    } catch (ShortBufferException e) {
        e.printStackTrace();
    }
    return sharedSecret;
}
 
开发者ID:Alezhka,项目名称:JWaves,代码行数:10,代码来源:Curve25519KeyAgreement.java

示例2: updateShouldMatchUsingByteByffer

import javax.crypto.ShortBufferException; //导入方法依赖的package包/类
@Test(expected=ShortBufferException.class)
public void updateShouldMatchUsingByteByffer() throws ShortBufferException {
	String[] keys = new String[] {
			"e61a38548694f1fd8cef251c518cc70bb613751c1ce52aa8",
			"2ff4e5c1cda84946798cc4ea8a1cf8df579e8a70f438b554",
			"9151232c854cf7977562a4e098d9d6ce892a80f79b408934",
			"9715c173b0a89292b3a88acbc7522085d5a1522f32109ea1" };
	String[] ivs = new String[] { "48a8ceb8551fd4ad",
			"76b779525bb0d1c0", "0e04ab4e1171451d", "19e6a2b2a690f026" };
	String[] inputs = new String[] { "e8fb0ceb4e912e16",
			"77340331c9c8e4f4", "2dab916e1b72c578", "7a3d5228d200e322" };
	String[] outputs = new String[] { "d2190e296a0bfc56",
			"b7f1fd226680a6ee", "f50d41fc9fe9ba71", "5e124bc1d28414e7" };


	ByteBuffer input = ByteBuffer.allocateDirect(Des3.BLOCK_SIZE);
	ByteBuffer output = ByteBuffer.allocateDirect(Des3.BLOCK_SIZE);
	ByteBuffer plain = ByteBuffer.allocateDirect(Des3.BLOCK_SIZE);
	ByteBuffer cipher = ByteBuffer.allocateDirect(Des3.BLOCK_SIZE);

	for (int i = 0; i < inputs.length; i++) {
		Des3 enc = new Des3(Util.h2b(keys[i]), Util.h2b(ivs[i]),
				Des3.ENCRYPT_MODE);
		Des3 dec = new Des3(Util.h2b(keys[i]), Util.h2b(ivs[i]),
				Des3.DECRYPT_MODE);

		input.put(Util.h2b(inputs[i])).rewind();
		output.put(Util.h2b(outputs[i])).rewind();

		try {
			assertEquals(Des3.BLOCK_SIZE, enc.update(input, cipher));
			assertEquals(Des3.BLOCK_SIZE, dec.update(output, plain));
		} catch (ShortBufferException e) {
			e.printStackTrace();
			fail();
		}

		assertEquals(Des3.BLOCK_SIZE, input.position());
		assertEquals(0, input.remaining());
		assertEquals(Des3.BLOCK_SIZE, output.position());
		assertEquals(0, output.remaining());
		assertEquals(Des3.BLOCK_SIZE, cipher.position());
		assertEquals(0, cipher.remaining());
		assertEquals(Des3.BLOCK_SIZE, plain.position());
		assertEquals(0, plain.remaining());

		input.rewind();
		output.rewind();
		cipher.rewind();
		plain.rewind();

		assertEquals(output, cipher);
		assertEquals(input, plain);
		
		/* tests ShortBufferException */
		if (i == inputs.length - 1) {
			cipher.position(cipher.limit());
			enc.update(input, cipher);
		}
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:62,代码来源:Des3Test.java

示例3: updateShouldMatchUsingByteArray

import javax.crypto.ShortBufferException; //导入方法依赖的package包/类
@Test(expected=ShortBufferException.class)
public void updateShouldMatchUsingByteArray() throws ShortBufferException {
	String[] keys = new String[] {
			"e61a38548694f1fd8cef251c518cc70bb613751c1ce52aa8",
			"2ff4e5c1cda84946798cc4ea8a1cf8df579e8a70f438b554",
			"9151232c854cf7977562a4e098d9d6ce892a80f79b408934",
			"9715c173b0a89292b3a88acbc7522085d5a1522f32109ea1" };
	String[] ivs = new String[] { "48a8ceb8551fd4ad",
			"76b779525bb0d1c0", "0e04ab4e1171451d", "19e6a2b2a690f026" };
	String[] inputs = new String[] { "e8fb0ceb4e912e16",
			"77340331c9c8e4f4", "2dab916e1b72c578", "7a3d5228d200e322" };
	String[] outputs = new String[] { "d2190e296a0bfc56",
			"b7f1fd226680a6ee", "f50d41fc9fe9ba71", "5e124bc1d28414e7" };

	for (int i = 0; i < inputs.length; i++) {
		Des3 enc = new Des3(Util.h2b(keys[i]), Util.h2b(ivs[i]),
				Des3.ENCRYPT_MODE);
		Des3 dec = new Des3(Util.h2b(keys[i]), Util.h2b(ivs[i]),
				Des3.DECRYPT_MODE);

		byte[] input = Util.h2b(inputs[i]);
		byte[] output = Util.h2b(outputs[i]);
		byte[] cipher = new byte[Des3.BLOCK_SIZE];
		byte[] plain = new byte[Des3.BLOCK_SIZE];

		if (i % 2 == 0) {
			cipher = enc.update(input, 0, input.length);
			plain = dec.update(output, 0, output.length);
		} else {
			try {
				assertEquals(Des3.BLOCK_SIZE,
						enc.update(input, 0, input.length, cipher, 0));
				assertEquals(Des3.BLOCK_SIZE,
						dec.update(output, 0, output.length, plain, 0));
			} catch (ShortBufferException e) {
				e.printStackTrace();
				fail();
			}
		}

		assertArrayEquals(output, cipher);
		assertArrayEquals(input, plain);
		
		/* tests ShortBufferException */
		if (i == inputs.length - 1)
			enc.update(input, 0, input.length, cipher, Des3.BLOCK_SIZE);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:49,代码来源:Des3Test.java


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