package org.bouncycastle.jce.provider; import java.security.InvalidKeyException; import java.security.PrivateKey; import java.security.PublicKey; import javax.crypto.interfaces.DHPrivateKey; import javax.crypto.interfaces.DHPublicKey; import org.bouncycastle.crypto.params.AsymmetricKeyParameter; import org.bouncycastle.crypto.params.DHParameters; import org.bouncycastle.crypto.params.DHPrivateKeyParameters; import org.bouncycastle.crypto.params.DHPublicKeyParameters; /* loaded from: classes6.dex */ public class DHUtil { public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey publicKey) throws InvalidKeyException { if (!(publicKey instanceof DHPublicKey)) { throw new InvalidKeyException("can't identify DH public key."); } DHPublicKey dHPublicKey = (DHPublicKey) publicKey; return new DHPublicKeyParameters(dHPublicKey.getY(), new DHParameters(dHPublicKey.getParams().getP(), dHPublicKey.getParams().getG(), null, dHPublicKey.getParams().getL())); } public static AsymmetricKeyParameter generatePrivateKeyParameter(PrivateKey privateKey) throws InvalidKeyException { if (!(privateKey instanceof DHPrivateKey)) { throw new InvalidKeyException("can't identify DH private key."); } DHPrivateKey dHPrivateKey = (DHPrivateKey) privateKey; return new DHPrivateKeyParameters(dHPrivateKey.getX(), new DHParameters(dHPrivateKey.getParams().getP(), dHPrivateKey.getParams().getG(), null, dHPrivateKey.getParams().getL())); } }