public PKCS10CertificationRequest( String var1, X509Name var2, PublicKey var3, ASN1Set var4, PrivateKey var5, String var6) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, SignatureException { String var7 = Strings.toUpperCase(var1); DERObjectIdentifier var8 = (DERObjectIdentifier) algorithms.get(var7); if (var8 == null) { throw new IllegalArgumentException("Unknown signature type requested"); } else if (var2 == null) { throw new IllegalArgumentException("subject must not be null"); } else if (var3 == null) { throw new IllegalArgumentException("public key must not be null"); } else { if (noParams.contains(var8)) { AlgorithmIdentifier var9 = new AlgorithmIdentifier(var8); this.sigAlgId = var9; } else if (params.containsKey(var7)) { DEREncodable var17 = (DEREncodable) params.get(var7); AlgorithmIdentifier var18 = new AlgorithmIdentifier(var8, var17); this.sigAlgId = var18; } else { AlgorithmIdentifier var19 = new AlgorithmIdentifier(var8, (DEREncodable) null); this.sigAlgId = var19; } try { ASN1Sequence var10 = (ASN1Sequence) ASN1Object.fromByteArray(var3.getEncoded()); SubjectPublicKeyInfo var11 = new SubjectPublicKeyInfo(var10); CertificationRequestInfo var12 = new CertificationRequestInfo(var2, var11, var4); this.reqInfo = var12; } catch (IOException var24) { throw new IllegalArgumentException("can\'t encode public key"); } Signature var13; if (var6 == null) { var13 = Signature.getInstance(var1); } else { var13 = Signature.getInstance(var1, var6); } var13.initSign(var5); try { byte[] var14 = this.reqInfo.getEncoded("DER"); var13.update(var14); } catch (Exception var23) { String var22 = "exception encoding TBS cert request - " + var23; throw new IllegalArgumentException(var22); } byte[] var15 = var13.sign(); DERBitString var16 = new DERBitString(var15); this.sigBits = var16; } }
public void writeObject(Object var1, String var2, char[] var3, SecureRandom var4) throws IOException { if (var1 instanceof KeyPair) { PrivateKey var5 = ((KeyPair) var1).getPrivate(); this.writeObject(var5); } else { String var8 = null; byte[] var9 = null; if (var1 instanceof RSAPrivateCrtKey) { var8 = "RSA PRIVATE KEY"; RSAPrivateCrtKey var10 = (RSAPrivateCrtKey) var1; BigInteger var11 = var10.getModulus(); BigInteger var12 = var10.getPublicExponent(); BigInteger var13 = var10.getPrivateExponent(); BigInteger var14 = var10.getPrimeP(); BigInteger var15 = var10.getPrimeQ(); BigInteger var16 = var10.getPrimeExponentP(); BigInteger var17 = var10.getPrimeExponentQ(); BigInteger var18 = var10.getCrtCoefficient(); var9 = (new RSAPrivateKeyStructure(var11, var12, var13, var14, var15, var16, var17, var18)) .getEncoded(); } else if (var1 instanceof DSAPrivateKey) { var8 = "DSA PRIVATE KEY"; DSAPrivateKey var22 = (DSAPrivateKey) var1; DSAParams var23 = var22.getParams(); ASN1EncodableVector var24 = new ASN1EncodableVector(); DERInteger var25 = new DERInteger(0); var24.add(var25); BigInteger var28 = var23.getP(); DERInteger var29 = new DERInteger(var28); var24.add(var29); BigInteger var32 = var23.getQ(); DERInteger var33 = new DERInteger(var32); var24.add(var33); BigInteger var36 = var23.getG(); DERInteger var37 = new DERInteger(var36); var24.add(var37); BigInteger var40 = var22.getX(); BigInteger var41 = var23.getG(); BigInteger var42 = var23.getP(); BigInteger var46 = var41.modPow(var40, var42); DERInteger var47 = new DERInteger(var46); var24.add(var47); DERInteger var52 = new DERInteger(var40); var24.add(var52); DERSequence var57 = new DERSequence(var24); var9 = var57.getEncoded(); } else if (var1 instanceof PrivateKey) { String var60 = ((PrivateKey) var1).getAlgorithm(); if ("ECDSA".equals(var60)) { var8 = "EC PRIVATE KEY"; var9 = PrivateKeyInfo.getInstance(ASN1Object.fromByteArray(((PrivateKey) var1).getEncoded())) .getPrivateKey() .getEncoded(); } } if (var8 != null && var9 != null) { String var61 = Strings.toUpperCase(var2); if (var61.equals("DESEDE")) { var61 = "DES-EDE3-CBC"; } byte var62; if (var61.startsWith("AES-")) { var62 = 16; } else { var62 = 8; } byte[] var63 = new byte[var62]; var4.nextBytes(var63); String var66 = this.provider; byte[] var68 = PEMUtilities.crypt((boolean) 1, var66, var9, var3, var61, var63); this.writeHeader(var8); String var72 = "Proc-Type: 4,ENCRYPTED"; this.write(var72); this.newLine(); String var73 = "DEK-Info: " + var61 + ","; this.write(var73); this.writeHexEncoded(var63); this.newLine(); this.newLine(); this.writeEncoded(var68); this.writeFooter(var8); } else { StringBuilder var19 = (new StringBuilder()).append("Object type not supported: "); String var20 = var1.getClass().getName(); String var21 = var19.append(var20).toString(); throw new IllegalArgumentException(var21); } } }