Skip to content

Commit

Permalink
expanded PBE support - relates to github #1846
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Dec 27, 2024
1 parent 6c5bcfb commit d84891a
Show file tree
Hide file tree
Showing 9 changed files with 649 additions and 106 deletions.
411 changes: 337 additions & 74 deletions prov/src/main/java/org/bouncycastle/jcajce/provider/symmetric/AES.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@ public CBC()
}
}

public static class CBC128
extends BaseBlockCipher
{
public CBC128()
{
super(128, new CBCBlockCipher(new CamelliaEngine()), 128);
}
}

public static class CBC192
extends BaseBlockCipher
{
public CBC192()
{
super(192, new CBCBlockCipher(new CamelliaEngine()), 128);
}
}

public static class CBC256
extends BaseBlockCipher
{
public CBC256()
{
super(256, new CBCBlockCipher(new CamelliaEngine()), 128);
}
}

public static class Wrap
extends BaseWrapCipher
{
Expand All @@ -67,6 +94,33 @@ public Wrap()
}
}

public static class Wrap128
extends BaseWrapCipher
{
public Wrap128()
{
super(128, new CamelliaWrapEngine());
}
}

public static class Wrap192
extends BaseWrapCipher
{
public Wrap192()
{
super(192, new CamelliaWrapEngine());
}
}

public static class Wrap256
extends BaseWrapCipher
{
public Wrap256()
{
super(256, new CamelliaWrapEngine());
}
}

public static class RFC3211Wrap
extends BaseWrapCipher
{
Expand Down Expand Up @@ -223,15 +277,15 @@ public void configure(ConfigurableProvider provider)
provider.addAlgorithm("Alg.Alias.AlgorithmParameterGenerator", NTTObjectIdentifiers.id_camellia256_cbc, "CAMELLIA");

provider.addAlgorithm("Cipher.CAMELLIA", PREFIX + "$ECB");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia128_cbc, PREFIX + "$CBC");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia192_cbc, PREFIX + "$CBC");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia256_cbc, PREFIX + "$CBC");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia128_cbc, PREFIX + "$CBC128");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia192_cbc, PREFIX + "$CBC192");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia256_cbc, PREFIX + "$CBC256");

provider.addAlgorithm("Cipher.CAMELLIARFC3211WRAP", PREFIX + "$RFC3211Wrap");
provider.addAlgorithm("Cipher.CAMELLIAWRAP", PREFIX + "$Wrap");
provider.addAlgorithm("Alg.Alias.Cipher", NTTObjectIdentifiers.id_camellia128_wrap, "CAMELLIAWRAP");
provider.addAlgorithm("Alg.Alias.Cipher", NTTObjectIdentifiers.id_camellia192_wrap, "CAMELLIAWRAP");
provider.addAlgorithm("Alg.Alias.Cipher", NTTObjectIdentifiers.id_camellia256_wrap, "CAMELLIAWRAP");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia128_wrap, PREFIX + "$Wrap128");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia192_wrap, PREFIX + "$Wrap192");
provider.addAlgorithm("Cipher", NTTObjectIdentifiers.id_camellia256_wrap, PREFIX + "$Wrap256");

provider.addAlgorithm("SecretKeyFactory.CAMELLIA", PREFIX + "$KeyFactory");
provider.addAlgorithm("Alg.Alias.SecretKeyFactory", NTTObjectIdentifiers.id_camellia128_cbc, "CAMELLIA");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static class ECB
{
public ECB()
{
super(new BlockCipherProvider()
super(128, new BlockCipherProvider()
{
public BlockCipher get()
{
Expand All @@ -54,7 +54,7 @@ public static class CBC
{
public CBC()
{
super(new CBCBlockCipher(new SEEDEngine()), 128);
super(128, new CBCBlockCipher(new SEEDEngine()), 128);
}
}

Expand All @@ -63,7 +63,7 @@ public static class Wrap
{
public Wrap()
{
super(new SEEDWrapEngine());
super(128, new SEEDWrapEngine());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,51 @@ public BlockCipher get()
}
}

public static class ECB128
extends BaseBlockCipher
{
public ECB128()
{
super(128, new BlockCipherProvider()
{
public BlockCipher get()
{
return new SerpentEngine();
}
});
}
}

public static class ECB192
extends BaseBlockCipher
{
public ECB192()
{
super(192, new BlockCipherProvider()
{
public BlockCipher get()
{
return new SerpentEngine();
}
});
}
}

public static class ECB256
extends BaseBlockCipher
{
public ECB256()
{
super(256, new BlockCipherProvider()
{
public BlockCipher get()
{
return new SerpentEngine();
}
});
}
}

public static class TECB
extends BaseBlockCipher
{
Expand All @@ -64,6 +109,33 @@ public CBC()
}
}

public static class CBC128
extends BaseBlockCipher
{
public CBC128()
{
super(128, new CBCBlockCipher(new SerpentEngine()), 128);
}
}

public static class CBC192
extends BaseBlockCipher
{
public CBC192()
{
super(192, new CBCBlockCipher(new SerpentEngine()), 128);
}
}

public static class CBC256
extends BaseBlockCipher
{
public CBC256()
{
super(256, new CBCBlockCipher(new SerpentEngine()), 128);
}
}

public static class CFB
extends BaseBlockCipher
{
Expand All @@ -73,6 +145,33 @@ public CFB()
}
}

public static class CFB128
extends BaseBlockCipher
{
public CFB128()
{
super(128, new BufferedBlockCipher(new CFBBlockCipher(new SerpentEngine(), 128)), 128);
}
}

public static class CFB192
extends BaseBlockCipher
{
public CFB192()
{
super(192, new BufferedBlockCipher(new CFBBlockCipher(new SerpentEngine(), 128)), 128);
}
}

public static class CFB256
extends BaseBlockCipher
{
public CFB256()
{
super(256, new BufferedBlockCipher(new CFBBlockCipher(new SerpentEngine(), 128)), 128);
}
}

public static class OFB
extends BaseBlockCipher
{
Expand All @@ -82,6 +181,33 @@ public OFB()
}
}

public static class OFB128
extends BaseBlockCipher
{
public OFB128()
{
super(128, new BufferedBlockCipher(new OFBBlockCipher(new SerpentEngine(), 128)), 128);
}
}

public static class OFB192
extends BaseBlockCipher
{
public OFB192()
{
super(192, new BufferedBlockCipher(new OFBBlockCipher(new SerpentEngine(), 128)), 128);
}
}

public static class OFB256
extends BaseBlockCipher
{
public OFB256()
{
super(256, new BufferedBlockCipher(new OFBBlockCipher(new SerpentEngine(), 128)), 128);
}
}

public static class KeyGen
extends BaseKeyGenerator
{
Expand Down Expand Up @@ -174,21 +300,21 @@ public void configure(ConfigurableProvider provider)
provider.addAlgorithm("KeyGenerator.Tnepres", PREFIX + "$TKeyGen");
provider.addAlgorithm("AlgorithmParameters.Tnepres", PREFIX + "$TAlgParams");

provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_ECB, PREFIX + "$ECB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_ECB, PREFIX + "$ECB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_ECB, PREFIX + "$ECB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_ECB, PREFIX + "$ECB128");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_ECB, PREFIX + "$ECB192");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_ECB, PREFIX + "$ECB256");

provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_CBC, PREFIX + "$CBC");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_CBC, PREFIX + "$CBC");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_CBC, PREFIX + "$CBC");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_CBC, PREFIX + "$CBC128");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_CBC, PREFIX + "$CBC192");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_CBC, PREFIX + "$CBC256");

provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_CFB, PREFIX + "$CFB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_CFB, PREFIX + "$CFB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_CFB, PREFIX + "$CFB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_CFB, PREFIX + "$CFB128");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_CFB, PREFIX + "$CFB192");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_CFB, PREFIX + "$CFB256");

provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_OFB, PREFIX + "$OFB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_OFB, PREFIX + "$OFB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_OFB, PREFIX + "$OFB");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_128_OFB, PREFIX + "$OFB128");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_192_OFB, PREFIX + "$OFB192");
provider.addAlgorithm("Cipher", GNUObjectIdentifiers.Serpent_256_OFB, PREFIX + "$OFB256");

addGMacAlgorithm(provider, "SERPENT", PREFIX + "$SerpentGMAC", PREFIX + "$KeyGen");
addGMacAlgorithm(provider, "TNEPRES", PREFIX + "$TSerpentGMAC", PREFIX + "$TKeyGen");
Expand Down
Loading

0 comments on commit d84891a

Please sign in to comment.