test_class.file: java_src/src/test/java/com/google/crypto/tink/subtle/RsaSsaPkcs1SignJceTest.java
test_class.identifier: RsaSsaPkcs1SignJceTest
test_case.body: @Test
    public void testBasicAgainstJce() throws Exception {
      int keySize = 2048;
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
      keyGen.initialize(keySize);
      KeyPair keyPair = keyGen.generateKeyPair();
      RSAPublicKey pub = (RSAPublicKey) keyPair.getPublic();
      RSAPrivateCrtKey priv = (RSAPrivateCrtKey) keyPair.getPrivate();
  
      // Sign with RsaSsaPkcs1SignJce.
      String message = "Hello";
      RsaSsaPkcs1SignJce signer = new RsaSsaPkcs1SignJce(priv, HashType.SHA256);
      byte[] signature = signer.sign(message.getBytes("UTF-8"));
  
      // Verify with JCE's Signature.
      Signature verifier = Signature.getInstance("SHA256withRSA");
      verifier.initVerify(pub);
      verifier.update(message.getBytes("UTF-8"));
      assertTrue(verifier.verify(signature));
    }
test_case.class_method_signature: RsaSsaPkcs1SignJceTest.testBasicAgainstJce()
test_case.full_signature: @Test public void testBasicAgainstJce()
test_case.identifier: testBasicAgainstJce
test_case.invocations: getInstance initialize generateKeyPair getPublic getPrivate sign getBytes getInstance initVerify update getBytes assertTrue verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testBasicAgainstJce()
focal_class.declarator: privateKey
focal_class.modifier: private final
focal_class.original_string: private final RSAPrivateCrtKey privateKey;
focal_class.type: RSAPrivateCrtKey
focal_class.var_name: privateKey
focal_class.declarator: publicKey
focal_class.modifier: private final
focal_class.original_string: private final RSAPublicKey publicKey;
focal_class.type: RSAPublicKey
focal_class.var_name: publicKey
focal_class.declarator: signatureAlgorithm
focal_class.modifier: private final
focal_class.original_string: private final String signatureAlgorithm;
focal_class.type: String
focal_class.var_name: signatureAlgorithm
focal_class.file: java_src/src/main/java/com/google/crypto/tink/subtle/RsaSsaPkcs1SignJce.java
focal_class.identifier: RsaSsaPkcs1SignJce
focal_class.interfaces: implements PublicKeySign
focal_class.class_method_signature: RsaSsaPkcs1SignJce.RsaSsaPkcs1SignJce(final RSAPrivateCrtKey priv, HashType hash)
focal_class.full_signature: public  RsaSsaPkcs1SignJce(final RSAPrivateCrtKey priv, HashType hash)
focal_class.identifier: RsaSsaPkcs1SignJce
focal_class.modifiers: public
focal_class.parameters: (final RSAPrivateCrtKey priv, HashType hash)
focal_class.signature:  RsaSsaPkcs1SignJce(final RSAPrivateCrtKey priv, HashType hash)
focal_class.class_method_signature: RsaSsaPkcs1SignJce.sign(final byte[] data)
focal_class.full_signature: @Override public byte[] sign(final byte[] data)
focal_class.identifier: sign
focal_class.modifiers: @Override public
focal_class.parameters: (final byte[] data)
focal_class.return: byte[]
focal_class.signature: byte[] sign(final byte[] data)
focal_method.body: @Override
    public byte[] sign(final byte[] data) throws GeneralSecurityException {
      Signature signer = EngineFactory.SIGNATURE.getInstance(signatureAlgorithm);
      signer.initSign(privateKey);
      signer.update(data);
      byte[] signature = signer.sign();
      // Verify the signature to prevent against faulty signature computation.
      Signature verifier = EngineFactory.SIGNATURE.getInstance(signatureAlgorithm);
      verifier.initVerify(publicKey);
      verifier.update(data);
      if (!verifier.verify(signature)) {
        throw new java.lang.RuntimeException("Security bug: RSA signature computation error");
      }
      return signature;
    }
focal_method.class_method_signature: RsaSsaPkcs1SignJce.sign(final byte[] data)
focal_method.full_signature: @Override public byte[] sign(final byte[] data)
focal_method.identifier: sign
focal_method.invocations: getInstance initSign update sign getInstance initVerify update verify
focal_method.modifiers: @Override public
focal_method.parameters: (final byte[] data)
focal_method.return: byte[]
focal_method.signature: byte[] sign(final byte[] data)