Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.pqc.jcajce.provider.mceliece;
  
  
 
 public abstract class McElieceKeyPairGeneratorSpi
     extends KeyPairGenerator
 {
         String algorithmName)
     {
         super(algorithmName);
     }

    
 
 
     public static class McElieceCCA2
         extends McElieceKeyPairGeneratorSpi
     {
 
 
 
         public McElieceCCA2()
         {
             super("McElieceCCA-2");
         }
 
         public McElieceCCA2(String s)
         {
             super(s);
         }
 
         public void initialize(AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException
         {
              = new McElieceCCA2KeyPairGenerator();
             super.initialize(params);
             ECCKeyGenParameterSpec ecc = (ECCKeyGenParameterSpec)params;
 
             McElieceCCA2KeyGenerationParameters mccca2KGParams = new McElieceCCA2KeyGenerationParameters(new SecureRandom(), new McElieceCCA2Parameters(ecc.getM(), ecc.getT()));
             .init(mccca2KGParams);
         }
 
         public void initialize(int keySizeSecureRandom random)
         {
             McElieceCCA2ParameterSpec paramSpec = new McElieceCCA2ParameterSpec();
 
             // call the initializer with the chosen parameters
             try
             {
                 this.initialize(paramSpec);
             }
             catch (InvalidAlgorithmParameterException ae)
             {
             }
         }
 
         public KeyPair generateKeyPair()
         {
             AsymmetricCipherKeyPair generateKeyPair = .generateKeyPair();
             McElieceCCA2PrivateKeyParameters sk = (McElieceCCA2PrivateKeyParameters)generateKeyPair.getPrivate();
             McElieceCCA2PublicKeyParameters pk = (McElieceCCA2PublicKeyParameters)generateKeyPair.getPublic();
 
             return new KeyPair(new BCMcElieceCCA2PublicKey(pk), new BCMcElieceCCA2PrivateKey(sk));
 
         }
 
     }

    
 
 
     public static class McEliece
         extends McElieceKeyPairGeneratorSpi
    {
        public McEliece()
        {
            super("McEliece");
        }
        public void initialize(AlgorithmParameterSpec params)
            throws InvalidAlgorithmParameterException
        {
             = new McElieceKeyPairGenerator();
            super.initialize(params);
            ECCKeyGenParameterSpec ecc = (ECCKeyGenParameterSpec)params;
            McElieceKeyGenerationParameters mccKGParams = new McElieceKeyGenerationParameters(new SecureRandom(), new McElieceParameters(ecc.getM(), ecc.getT()));
            .init(mccKGParams);
        }
        public void initialize(int keySizeSecureRandom random)
        {
            ECCKeyGenParameterSpec paramSpec = new ECCKeyGenParameterSpec();
            // call the initializer with the chosen parameters
            try
            {
                this.initialize(paramSpec);
            }
            catch (InvalidAlgorithmParameterException ae)
            {
            }
        }
        public KeyPair generateKeyPair()
        {
            AsymmetricCipherKeyPair generateKeyPair = .generateKeyPair();
            McEliecePrivateKeyParameters sk = (McEliecePrivateKeyParameters)generateKeyPair.getPrivate();
            McEliecePublicKeyParameters pk = (McEliecePublicKeyParameters)generateKeyPair.getPublic();
            return new KeyPair(new BCMcEliecePublicKey(pk), new BCMcEliecePrivateKey(sk));
        }
    }
New to GrepCode? Check out our FAQ X