EncryptedData : 0x30 L1 EncryptedData sequence | +--> 0xA1 L2 etype tag | | | +--> 0x02 L2-1 etype (int) | +--> [0xA2 L3 kvno tag | | | +--> 0x30 L3-1 kvno (int)] (optional) | +--> 0xA2 L4 cipher tag | +--> 0x04 L4-1 cipher (OCTET STRING)
318319320321322323324325326327328
PaEncTsEnc encryptedTimeStamp = new PaEncTsEnc( timeStamp, 0 ); EncryptedData encryptedData = lockBox.seal( clientKey, encryptedTimeStamp, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY ); ByteBuffer buffer = ByteBuffer.allocate( encryptedData.computeLength() ); byte[] encodedEncryptedData = encryptedData.encode( buffer ).array(); PaData preAuth = new PaData(); preAuth.setPaDataType( PaDataType.PA_ENC_TIMESTAMP ); preAuth.setPaDataValue( encodedEncryptedData );
7879808182838485868788
EncryptionKey clientKey = getEncryptionKey( clientPrincipal, passPhrase ); EncryptedData encryptedData = lockBox.seal( clientKey, encryptedTimeStamp, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY ); ByteBuffer buffer = ByteBuffer.allocate( encryptedData.computeLength() ); byte[] encodedEncryptedData = encryptedData.encode( buffer ).array(); PaData preAuth = new PaData(); preAuth.setPaDataType( PaDataType.PA_ENC_TIMESTAMP ); preAuth.setPaDataValue( encodedEncryptedData );
108109110111112113114115116117118
assertEquals( EncryptionType.AES256_CTS_HMAC_SHA1_96, encryptedData.getEType() ); assertEquals( 5, encryptedData.getKvno() ); assertTrue( Arrays.equals( Strings.getBytesUtf8( "abcdef" ), encryptedData.getCipher() ) ); // Check the encoding ByteBuffer bb = ByteBuffer.allocate( encryptedData.computeLength() ); try { bb = encryptedData.encode( bb );
181182183184185186187188189190191
assertEquals( EncryptionType.AES256_CTS_HMAC_SHA1_96, encryptedData.getEType() ); assertFalse( encryptedData.hasKvno() ); assertTrue( Arrays.equals( Strings.getBytesUtf8( "abcdef" ), encryptedData.getCipher() ) ); // Check the encoding ByteBuffer bb = ByteBuffer.allocate( encryptedData.computeLength() ); try { bb = encryptedData.encode( bb );
4950515253545556575859
public void testEncodingEncryptedData() throws Exception { EncryptedData ed = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, 1, new byte[] { 0x01, 0x02, 0x03, 0x04 } ); ByteBuffer encoded = ByteBuffer.allocate( ed.computeLength() ); ed.encode( encoded ); byte[] expectedResult = new byte[] {
7374757677787980818283
@Test public void testEncodingEncryptedDataNullCipher() throws Exception { EncryptedData ed = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, 1, null ); ByteBuffer encoded = ByteBuffer.allocate( ed.computeLength() ); ed.encode( encoded ); byte[] expectedResult = new byte[] {
9899100101102103104105106107108
public void testEncodingEncryptedDataNoKvno() throws Exception { EncryptedData ed = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, new byte[] { 0x01, 0x02, 0x03, 0x04 } ); ByteBuffer encoded = ByteBuffer.allocate( ed.computeLength() ); ed.encode( encoded ); byte[] expectedResult = new byte[] {
120121122123124125126127128129130
@Test public void testEncodingEncryptedDataNoKvnoNullCipher() throws Exception { EncryptedData ed = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, null ); ByteBuffer encoded = ByteBuffer.allocate( ed.computeLength() ); ed.encode( encoded ); byte[] expectedResult = new byte[] {
306307308309310311312313314315316
EncryptionKey clientKey = getEncryptionKey( clientPrincipal, passPhrase ); EncryptedData encryptedData = lockBox.seal( clientKey, encryptedTimeStamp, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY ); ByteBuffer buffer = ByteBuffer.allocate( encryptedData.computeLength() ); byte[] encodedEncryptedData = encryptedData.encode( buffer ).array(); PaData preAuth = new PaData(); preAuth.setPaDataType( PaDataType.PA_PK_AS_REQ ); preAuth.setPaDataValue( encodedEncryptedData );
7778798081828384858687