@SuppressWarnings("UnusedException")
  private static RsaSsaPkcs1PublicKey parsePublicKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(PUBLIC_TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to RsaSsaPkcs1ProtoSerialization.parsePublicKey: "
              + serialization.getTypeUrl());
    }
    try {
      com.google.crypto.tink.proto.RsaSsaPkcs1PublicKey protoKey =
          com.google.crypto.tink.proto.RsaSsaPkcs1PublicKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      BigInteger modulus = decodeBigInteger(protoKey.getN());
      int modulusSizeInBits = modulus.bitLength();
      RsaSsaPkcs1Parameters parameters =
          RsaSsaPkcs1Parameters.builder()
              .setHashType(HASH_TYPE_CONVERTER.fromProtoEnum(protoKey.getParams().getHashType()))
              .setPublicExponent(decodeBigInteger(protoKey.getE()))
              .setModulusSizeBits(modulusSizeInBits)
              .setVariant(VARIANT_CONVERTER.fromProtoEnum(serialization.getOutputPrefixType()))
              .build();
      return RsaSsaPkcs1PublicKey.builder()
          .setParameters(parameters)
          .setModulus(modulus)
          .setIdRequirement(serialization.getIdRequirementOrNull())
          .build();
    } catch (InvalidProtocolBufferException | IllegalArgumentException e) {
      throw new GeneralSecurityException("Parsing RsaSsaPkcs1PublicKey failed");
    }
  }
Encodes a BigInteger using a big-endian encoding.
java_src/src/main/java/com/google/crypto/tink/signature/internal/RsaSsaPkcs1ProtoSerialization.java