Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.jcajce.provider.asymmetric.dh;
  
  
  
 
 public class AlgorithmParametersSpi
 {
     DHParameterSpec     currentSpec;
 
     protected boolean isASN1FormatString(String format)
     {
         return format == null || format.equals("ASN.1");
     }
 
         Class paramSpec)
         throws InvalidParameterSpecException
     {
         if (paramSpec == null)
         {
             throw new NullPointerException("argument to getParameterSpec must not be null");
         }
 
         return localEngineGetParameterSpec(paramSpec);
     }




        
Return the PKCS#3 ASN.1 structure DHParameter.

  DHParameter ::= SEQUENCE {
                   prime INTEGER, -- p
                   base INTEGER, -- g
                   privateValueLength INTEGER OPTIONAL}
 
 
         protected byte[] engineGetEncoded() 
         {
             DHParameter dhP = new DHParameter(.getP(), .getG(), .getL());
 
             try
             {
                 return dhP.getEncoded(.);
             }
             catch (IOException e)
             {
                 throw new RuntimeException("Error encoding DHParameters");
             }
         }
 
         protected byte[] engineGetEncoded(
             String format
         {
             if (isASN1FormatString(format))
             {
                 return engineGetEncoded();
             }
 
             return null;
         }
 
             Class paramSpec
             throws InvalidParameterSpecException
         {
             if (paramSpec == DHParameterSpec.class)
             {
                 return ;
             }
 
             throw new InvalidParameterSpecException("unknown parameter spec passed to DH parameters object.");
         }
 
         protected void engineInit(
             AlgorithmParameterSpec paramSpec
             throws InvalidParameterSpecException
         {
             if (!(paramSpec instanceof DHParameterSpec))
             {
                 throw new InvalidParameterSpecException("DHParameterSpec required to initialise a Diffie-Hellman algorithm parameters object");
             }
 
             this. = (DHParameterSpec)paramSpec;
         }
 
         protected void engineInit(
             byte[] params
             throws IOException
         {
            try
            {
                DHParameter dhP = DHParameter.getInstance(params);
                if (dhP.getL() != null)
                {
                     = new DHParameterSpec(dhP.getP(), dhP.getG(), dhP.getL().intValue());
                }
                else
                {
                     = new DHParameterSpec(dhP.getP(), dhP.getG());
                }
            }
            catch (ClassCastException e)
            {
                throw new IOException("Not a valid DH Parameter encoding.");
            }
            catch (ArrayIndexOutOfBoundsException e)
            {
                throw new IOException("Not a valid DH Parameter encoding.");
            }
        }
        protected void engineInit(
            byte[] params,
            String format
            throws IOException
        {
            if (isASN1FormatString(format))
            {
                engineInit(params);
            }
            else
            {
                throw new IOException("Unknown parameter format " + format);
            }
        }
        protected String engineToString() 
        {
            return "Diffie-Hellman Parameters";
        }
New to GrepCode? Check out our FAQ X