Information

0
Story Points

Technologies

Decompiled Java File
package iaik.security.rsa;

import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactorySpi;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateCrtKeySpec;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.security.spec.X509EncodedKeySpec;

public final class RSAKeyFactory extends KeyFactorySpi {
   // $FF: synthetic field
   static Class e;
   // $FF: synthetic field
   static Class c;
   // $FF: synthetic field
   static Class d;
   // $FF: synthetic field
   static Class a;
   // $FF: synthetic field
   static Class b;

   static Class a(String var0) {
      try {
         return Class.forName(var0);
      } catch (ClassNotFoundException var2) {
         throw new NoClassDefFoundError(var2.getMessage());
      }
   }

   protected Key engineTranslateKey(Key var1) throws InvalidKeyException {
      BigInteger var2;
      BigInteger var3;
      if(var1 instanceof RSAPublicKey) {
         var2 = ((RSAPublicKey)var1).getModulus();
         var3 = ((RSAPublicKey)var1).getPublicExponent();
         return new iaik.security.rsa.RSAPublicKey(var2, var3);
      } else if(var1 instanceof RSAPrivateKey) {
         var2 = ((RSAPrivateKey)var1).getModulus();
         var3 = ((RSAPrivateKey)var1).getPrivateExponent();
         if(var1 instanceof RSAPrivateCrtKey) {
            BigInteger var4 = ((RSAPrivateCrtKey)var1).getPublicExponent();
            BigInteger var5 = ((RSAPrivateCrtKey)var1).getPrimeP();
            BigInteger var6 = ((RSAPrivateCrtKey)var1).getPrimeQ();
            BigInteger var7 = ((RSAPrivateCrtKey)var1).getPrimeExponentP();
            BigInteger var8 = ((RSAPrivateCrtKey)var1).getPrimeExponentQ();
            BigInteger var9 = ((RSAPrivateCrtKey)var1).getCrtCoefficient();
            return new iaik.security.rsa.RSAPrivateKey(var2, var4, var3, var5, var6, var7, var8, var9);
         } else {
            return new iaik.security.rsa.RSAPrivateKey(var2, var3);
         }
      } else {
         throw new InvalidKeyException("Only keys of type RSAPublicKey and RSAPrivateKey can be translated.");
      }
   }

   protected KeySpec engineGetKeySpec(Key var1, Class var2) throws InvalidKeySpecException {
      if(var1 instanceof iaik.security.rsa.RSAPublicKey) {
         if((b != null?b:(b = a("java.security.spec.RSAPublicKeySpec"))).isAssignableFrom(var2)) {
            iaik.security.rsa.RSAPublicKey var4 = (iaik.security.rsa.RSAPublicKey)var1;
            return new RSAPublicKeySpec(var4.getModulus(), var4.getPublicExponent());
         } else if((a != null?a:(a = a("java.security.spec.X509EncodedKeySpec"))).isAssignableFrom(var2)) {
            return new X509EncodedKeySpec(var1.getEncoded());
         } else {
            throw new InvalidKeySpecException("Can\'t convert key to KeySpec.");
         }
      } else if(var1 instanceof iaik.security.rsa.RSAPrivateKey) {
         iaik.security.rsa.RSAPrivateKey var3 = (iaik.security.rsa.RSAPrivateKey)var1;
         if((d != null?d:(d = a("java.security.spec.RSAPrivateCrtKeySpec"))).isAssignableFrom(var2)) {
            return new RSAPrivateCrtKeySpec(var3.getModulus(), var3.getPublicExponent(), var3.getPrivateExponent(), var3.getPrimeP(), var3.getPrimeQ(), var3.getPrimeExponentP(), var3.getPrimeExponentQ(), var3.getCrtCoefficient());
         } else if((c != null?c:(c = a("java.security.spec.RSAPrivateKeySpec"))).isAssignableFrom(var2)) {
            return new RSAPrivateKeySpec(var3.getModulus(), var3.getPrivateExponent());
         } else if((e != null?e:(e = a("java.security.spec.PKCS8EncodedKeySpec"))).isAssignableFrom(var2)) {
            return new PKCS8EncodedKeySpec(var3.getEncoded());
         } else {
            throw new InvalidKeySpecException("Can\'t convert key to KeySpec.");
         }
      } else {
         throw new InvalidKeySpecException("Can only convert RSA keys.");
      }
   }

   protected PublicKey engineGeneratePublic(KeySpec var1) throws InvalidKeySpecException {
      try {
         if(var1 instanceof RSAPublicKeySpec) {
            return new iaik.security.rsa.RSAPublicKey((RSAPublicKeySpec)var1);
         } else if(var1 instanceof X509EncodedKeySpec) {
            return new iaik.security.rsa.RSAPublicKey(((X509EncodedKeySpec)var1).getEncoded());
         } else {
            throw new InvalidKeySpecException("Only RSA key specs allowed.");
         }
      } catch (InvalidKeyException var2) {
         throw new InvalidKeySpecException("Invalid KeySpec.");
      }
   }

   protected PrivateKey engineGeneratePrivate(KeySpec var1) throws InvalidKeySpecException {
      try {
         if(var1 instanceof RSAPrivateCrtKeySpec) {
            return new iaik.security.rsa.RSAPrivateKey((RSAPrivateCrtKeySpec)var1);
         } else if(var1 instanceof RSAPrivateKeySpec) {
            return new iaik.security.rsa.RSAPrivateKey((RSAPrivateKeySpec)var1);
         } else if(var1 instanceof PKCS8EncodedKeySpec) {
            return new iaik.security.rsa.RSAPrivateKey(((PKCS8EncodedKeySpec)var1).getEncoded());
         } else {
            throw new InvalidKeySpecException("Only RSA key specs allowed.");
         }
      } catch (InvalidKeyException var2) {
         throw new InvalidKeySpecException("Invalid KeySpec.");
      }
   }
}
Page generated: Oct 19, 2017 2:34:48 PM