Package org.apache.directory.server.kerberos.shared.messages.value

Examples of org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey


        Map<EncryptionType, EncryptionKey> map = KerberosKeyFactory.getKerberosKeys( principalName, passPhrase,
            encryptionTypes );

        assertEquals( "List length", 1, map.values().size() );

        EncryptionKey kerberosKey = map.get( EncryptionType.AES128_CTS_HMAC_SHA1_96 );

        EncryptionType keyType = kerberosKey.getKeyType();
        int keyLength = kerberosKey.getKeyValue().length;
        byte[] keyBytes = kerberosKey.getKeyValue();

        assertEquals( keyType, EncryptionType.AES128_CTS_HMAC_SHA1_96 );
        assertEquals( keyLength, 16 );
        byte[] expectedBytes = new byte[]
            { ( byte ) 0xAD, ( byte ) 0x21, ( byte ) 0x4B, ( byte ) 0x38, ( byte ) 0xB6, ( byte ) 0x9D, ( byte ) 0xFC,
View Full Code Here


        assertTrue( "Keytab version", Arrays.equals( Keytab.VERSION_52, keytab.getKeytabVersion() ) );
        assertEquals( "Entries size", 1, keytab.getEntries().size() );

        KeytabEntry entry = keytab.getEntries().get( 0 );
        EncryptionKey key = entry.getKey();

        try
        {
            assertTrue( DESKeySpec.isParityAdjusted( key.getKeyValue(), 0 ) );
        }
        catch ( InvalidKeyException ike )
        {
            fail( "Key is invalid." );
        }
View Full Code Here

        assertTrue( "Keytab version", Arrays.equals( Keytab.VERSION_52, keytab.getKeytabVersion() ) );
        assertEquals( "Entries size", 1, keytab.getEntries().size() );

        KeytabEntry entry = keytab.getEntries().get( 0 );
        EncryptionKey key = entry.getKey();

        try
        {
            assertTrue( DESKeySpec.isParityAdjusted( key.getKeyValue(), 0 ) );
        }
        catch ( InvalidKeyException ike )
        {
            fail( "Key is invalid." );
        }
View Full Code Here

        encryptionTypes.add( EncryptionType.AES256_CTS_HMAC_SHA1_96 );

        Map<EncryptionType, EncryptionKey> map = KerberosKeyFactory.getKerberosKeys( principalName, passPhrase,
            encryptionTypes );

        EncryptionKey kerberosKey = map.get( EncryptionType.AES256_CTS_HMAC_SHA1_96 );

        if ( kerberosKey != null )
        {
            assertEquals( "List length", 1, map.values().size() );

            EncryptionType keyType = kerberosKey.getKeyType();
            int keyLength = kerberosKey.getKeyValue().length;
            byte[] keyBytes = kerberosKey.getKeyValue();

            assertEquals( keyType, EncryptionType.AES256_CTS_HMAC_SHA1_96 );
            assertEquals( keyLength, 32 );
            byte[] expectedBytes = new byte[]
                { ( byte ) 0x3D, ( byte ) 0x33, ( byte ) 0x31, ( byte ) 0x8F, ( byte ) 0xBE, ( byte ) 0x47,
View Full Code Here

        KerberosTime timeStamp = new KerberosTime( date );

        byte keyVersion = 1;
        String passPhrase = "secret";
        Map<EncryptionType, EncryptionKey> keys = KerberosKeyFactory.getKerberosKeys( principalName, passPhrase );
        EncryptionKey key = keys.get( EncryptionType.DES_CBC_MD5 );

        return new KeytabEntry( principalName, principalType, timeStamp, keyVersion, key );
    }
View Full Code Here

        String principalName = "hnelson@EXAMPLE.COM";
        String passPhrase = "secret";

        Map<EncryptionType, EncryptionKey> map = KerberosKeyFactory.getKerberosKeys( principalName, passPhrase );

        EncryptionKey kerberosKey = map.get( EncryptionType.DES_CBC_MD5 );

        EncryptionType keyType = kerberosKey.getKeyType();
        int keyLength = kerberosKey.getKeyValue().length;
        byte[] keyBytes = kerberosKey.getKeyValue();

        assertEquals( keyType, EncryptionType.DES_CBC_MD5 );
        assertEquals( keyLength, 8 );
        byte[] expectedBytes = new byte[]
            { ( byte ) 0xF4, ( byte ) 0xA7, ( byte ) 0x13, ( byte ) 0x64, ( byte ) 0x8A, ( byte ) 0x61, ( byte ) 0xCE,
                ( byte ) 0x5B };
        assertTrue( Arrays.equals( expectedBytes, keyBytes ) );

        kerberosKey = map.get( EncryptionType.DES3_CBC_SHA1_KD );
        keyType = kerberosKey.getKeyType();
        keyLength = kerberosKey.getKeyValue().length;
        keyBytes = kerberosKey.getKeyValue();

        assertEquals( keyType, EncryptionType.DES3_CBC_SHA1_KD );
        assertEquals( keyLength, 24 );
        expectedBytes = new byte[]
            { ( byte ) 0x57, ( byte ) 0x07, ( byte ) 0xCE, ( byte ) 0x29, ( byte ) 0x52, ( byte ) 0x92, ( byte ) 0x2C,
                ( byte ) 0x1C, ( byte ) 0x8C, ( byte ) 0xBF, ( byte ) 0x43, ( byte ) 0xC2, ( byte ) 0x3D,
                ( byte ) 0x8F, ( byte ) 0x8C, ( byte ) 0x5E, ( byte ) 0x9E, ( byte ) 0x8C, ( byte ) 0xF7,
                ( byte ) 0x5D, ( byte ) 0x3E, ( byte ) 0x4A, ( byte ) 0x5E, ( byte ) 0x25 };
        assertTrue( Arrays.equals( expectedBytes, keyBytes ) );

        kerberosKey = map.get( EncryptionType.RC4_HMAC );
        keyType = kerberosKey.getKeyType();
        keyLength = kerberosKey.getKeyValue().length;
        keyBytes = kerberosKey.getKeyValue();

        assertEquals( keyType, EncryptionType.RC4_HMAC );
        assertEquals( keyLength, 16 );
        expectedBytes = new byte[]
            { ( byte ) 0x87, ( byte ) 0x8D, ( byte ) 0x80, ( byte ) 0x14, ( byte ) 0x60, ( byte ) 0x6C, ( byte ) 0xDA,
                ( byte ) 0x29, ( byte ) 0x67, ( byte ) 0x7A, ( byte ) 0x44, ( byte ) 0xEF, ( byte ) 0xA1,
                ( byte ) 0x35, ( byte ) 0x3F, ( byte ) 0xC7 };
        assertTrue( Arrays.equals( expectedBytes, keyBytes ) );

        kerberosKey = map.get( EncryptionType.AES128_CTS_HMAC_SHA1_96 );
        keyType = kerberosKey.getKeyType();
        keyLength = kerberosKey.getKeyValue().length;
        keyBytes = kerberosKey.getKeyValue();

        assertEquals( keyType, EncryptionType.AES128_CTS_HMAC_SHA1_96 );
        assertEquals( keyLength, 16 );
        expectedBytes = new byte[]
            { ( byte ) 0xAD, ( byte ) 0x21, ( byte ) 0x4B, ( byte ) 0x38, ( byte ) 0xB6, ( byte ) 0x9D, ( byte ) 0xFC,
                ( byte ) 0xCA, ( byte ) 0xAC, ( byte ) 0xF1, ( byte ) 0x5F, ( byte ) 0x34, ( byte ) 0x6D,
                ( byte ) 0x41, ( byte ) 0x7B, ( byte ) 0x90 };
        assertTrue( Arrays.equals( expectedBytes, keyBytes ) );

        kerberosKey = map.get( EncryptionType.AES256_CTS_HMAC_SHA1_96 );

        if ( kerberosKey != null )
        {
            keyType = kerberosKey.getKeyType();
            keyLength = kerberosKey.getKeyValue().length;
            keyBytes = kerberosKey.getKeyValue();

            assertEquals( keyType, EncryptionType.AES256_CTS_HMAC_SHA1_96 );
            assertEquals( keyLength, 32 );
            expectedBytes = new byte[]
                { ( byte ) 0x3D, ( byte ) 0x33, ( byte ) 0x31, ( byte ) 0x8F, ( byte ) 0xBE, ( byte ) 0x47,
View Full Code Here

    {
        PaData[] paData = new PaData[1];

        EncryptedTimeStamp encryptedTimeStamp = new EncryptedTimeStamp( timeStamp, 0 );

        EncryptionKey clientKey = getEncryptionKey( clientPrincipal, passPhrase );

        EncryptedData encryptedData = lockBox.seal( clientKey, encryptedTimeStamp, KeyUsage.NUMBER1 );

        byte[] encodedEncryptedData = EncryptedDataEncoder.encode( encryptedData );
View Full Code Here

     */
    protected EncryptionKey getEncryptionKey( KerberosPrincipal principal, String passPhrase )
    {
        KerberosKey kerberosKey = new KerberosKey( principal, passPhrase.toCharArray(), "DES" );
        byte[] keyBytes = kerberosKey.getEncoded();
        EncryptionKey key = new EncryptionKey( EncryptionType.DES_CBC_MD5, keyBytes );

        return key;
    }
View Full Code Here

    @Test
    public void testPlainTextSizeLessThanBlockSize() throws Exception
    {
        KerberosKey key = new KerberosKey( new KerberosPrincipal( "hnelson@EXAMPLE.COM" ), PASSWORD, "DES" );
        byte[] keyBytes = key.getEncoded();
        EncryptionKey encryptionKey = new EncryptionKey( EncryptionType.DES_CBC_CRC, keyBytes );

        byte[] plainText =
            { 1, 2, 3, 4, 5, 6, 7 };

        DesCbcCrcEncryption encryption = new DesCbcCrcEncryption();
View Full Code Here

    @Test
    public void testPlainTextSizeEqualsBlockSize() throws Exception
    {
        KerberosKey key = new KerberosKey( new KerberosPrincipal( "hnelson@EXAMPLE.COM" ), PASSWORD, "DES" );
        byte[] keyBytes = key.getEncoded();
        EncryptionKey encryptionKey = new EncryptionKey( EncryptionType.DES_CBC_CRC, keyBytes );

        byte[] plainText =
            { 1, 2, 3, 4, 5, 6, 7, 8 };

        DesCbcCrcEncryption encryption = new DesCbcCrcEncryption();
View Full Code Here

TOP

Related Classes of org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.