Java Code Examples for java.security.spec.RSAPublicKeySpec#getModulus()

The following examples show how to use java.security.spec.RSAPublicKeySpec#getModulus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewCertificateContract.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private int getKeySize(SubjectPublicKeyInfo subjectPKInfo) {
   try {
      X509EncodedKeySpec xspec = new X509EncodedKeySpec((new DERBitString(subjectPKInfo.getEncoded())).getBytes());
      AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
      PublicKey publicKey = KeyFactory.getInstance(keyAlg.getAlgorithm().getId()).generatePublic(xspec);
      String algorithm = publicKey.getAlgorithm();
      KeyFactory keyFact = KeyFactory.getInstance(algorithm);
      RSAPublicKeySpec keySpec = (RSAPublicKeySpec)keyFact.getKeySpec(publicKey, RSAPublicKeySpec.class);
      BigInteger modulus = keySpec.getModulus();
      return modulus.toString(2).length();
   } catch (Exception var9) {
      throw new IllegalArgumentException(var9);
   }
}
 
Example 2
Source File: NewCertificateContract.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private int getKeySize(SubjectPublicKeyInfo subjectPKInfo) {
   try {
      X509EncodedKeySpec xspec = new X509EncodedKeySpec((new DERBitString(subjectPKInfo.getEncoded())).getBytes());
      AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
      PublicKey publicKey = KeyFactory.getInstance(keyAlg.getAlgorithm().getId()).generatePublic(xspec);
      String algorithm = publicKey.getAlgorithm();
      KeyFactory keyFact = KeyFactory.getInstance(algorithm);
      RSAPublicKeySpec keySpec = (RSAPublicKeySpec)keyFact.getKeySpec(publicKey, RSAPublicKeySpec.class);
      BigInteger modulus = keySpec.getModulus();
      return modulus.toString(2).length();
   } catch (Exception var9) {
      throw new IllegalArgumentException(var9);
   }
}
 
Example 3
Source File: NewCertificateContract.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private static int getKeySize(SubjectPublicKeyInfo subjectPKInfo) {
   try {
      X509EncodedKeySpec xspec = new X509EncodedKeySpec((new DERBitString(subjectPKInfo.getEncoded())).getBytes());
      AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
      PublicKey publicKey = KeyFactory.getInstance(keyAlg.getAlgorithm().getId()).generatePublic(xspec);
      String algorithm = publicKey.getAlgorithm();
      KeyFactory keyFact = KeyFactory.getInstance(algorithm);
      RSAPublicKeySpec keySpec = (RSAPublicKeySpec)keyFact.getKeySpec(publicKey, RSAPublicKeySpec.class);
      BigInteger modulus = keySpec.getModulus();
      return modulus.toString(2).length();
   } catch (Exception var8) {
      throw new IllegalArgumentException(var8);
   }
}
 
Example 4
Source File: NewCertificateContract.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private static int getKeySize(SubjectPublicKeyInfo subjectPKInfo) {
   try {
      X509EncodedKeySpec xspec = new X509EncodedKeySpec((new DERBitString(subjectPKInfo.getEncoded())).getBytes());
      AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
      PublicKey publicKey = KeyFactory.getInstance(keyAlg.getAlgorithm().getId()).generatePublic(xspec);
      String algorithm = publicKey.getAlgorithm();
      KeyFactory keyFact = KeyFactory.getInstance(algorithm);
      RSAPublicKeySpec keySpec = (RSAPublicKeySpec)keyFact.getKeySpec(publicKey, RSAPublicKeySpec.class);
      BigInteger modulus = keySpec.getModulus();
      return modulus.toString(2).length();
   } catch (Exception var8) {
      throw new IllegalArgumentException(var8);
   }
}
 
Example 5
Source File: NewCertificateContract.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private int getKeySize(SubjectPublicKeyInfo subjectPKInfo) {
   try {
      X509EncodedKeySpec xspec = new X509EncodedKeySpec((new DERBitString(subjectPKInfo.getEncoded())).getBytes());
      AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
      PublicKey publicKey = KeyFactory.getInstance(keyAlg.getAlgorithm().getId()).generatePublic(xspec);
      String algorithm = publicKey.getAlgorithm();
      KeyFactory keyFact = KeyFactory.getInstance(algorithm);
      RSAPublicKeySpec keySpec = (RSAPublicKeySpec)keyFact.getKeySpec(publicKey, RSAPublicKeySpec.class);
      BigInteger modulus = keySpec.getModulus();
      return modulus.toString(2).length();
   } catch (Exception var9) {
      throw new IllegalArgumentException(var9);
   }
}
 
Example 6
Source File: BCRSAPublicKey.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
BCRSAPublicKey(
    RSAPublicKeySpec spec)
{
    this.algorithmIdentifier = DEFAULT_ALGORITHM_IDENTIFIER;
    this.modulus = spec.getModulus();
    this.publicExponent = spec.getPublicExponent();
}
 
Example 7
Source File: BCRSAPublicKey.java    From ripple-lib-java with ISC License 5 votes vote down vote up
BCRSAPublicKey(
    RSAPublicKeySpec spec)
{
    this.algorithmIdentifier = DEFAULT_ALGORITHM_IDENTIFIER;
    this.modulus = spec.getModulus();
    this.publicExponent = spec.getPublicExponent();
}
 
Example 8
Source File: JCERSAPublicKey.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
JCERSAPublicKey(
    RSAPublicKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.publicExponent = spec.getPublicExponent();
}
 
Example 9
Source File: JCERSAPublicKey.java    From TorrentEngine with GNU General Public License v3.0 4 votes vote down vote up
JCERSAPublicKey(
    RSAPublicKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.publicExponent = spec.getPublicExponent();
}
 
Example 10
Source File: IosRSAKey.java    From j2objc with Apache License 2.0 4 votes vote down vote up
public IosRSAPublicKey(RSAPublicKeySpec spec) {
  super(spec.getModulus());
  this.publicExponent = spec.getPublicExponent();
}
 
Example 11
Source File: JCERSAPublicKey.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
JCERSAPublicKey(
    RSAPublicKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.publicExponent = spec.getPublicExponent();
}
 
Example 12
Source File: JCERSAPublicKey.java    From ripple-lib-java with ISC License 4 votes vote down vote up
JCERSAPublicKey(
    RSAPublicKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.publicExponent = spec.getPublicExponent();
}