Code example for AlgorithmParameters

Methods: getEncodedgetParameterSpec

0
            fail("JCE decrypt with additional data and GCMParameterSpec failed."); 
        } 
 
        AlgorithmParameters algParams = eax.getParameters();
 
        byte[] encParams = algParams.getEncoded();
 
        GCMParameters gcmParameters = GCMParameters.getInstance(encParams);
 
        if (!Arrays.areEqual(spec.getIV(), gcmParameters.getNonce()) || spec.getTLen() != gcmParameters.getIcvLen())
        { 
            fail("parameters mismatch"); 
        } 
 
        GCMParameterSpec gcmSpec = algParams.getParameterSpec(GCMParameterSpec.class);
 
        if (!Arrays.areEqual(gcmSpec.getIV(), gcmParameters.getNonce()) || gcmSpec.getTLen() != gcmParameters.getIcvLen() * 8)
        { 
            fail("spec parameters mismatch"); 
        }