@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.kms.v1.AsymmetricSignResponse)) { return super.equals(obj); } com.google.cloud.kms.v1.AsymmetricSignResponse other = (com.google.cloud.kms.v1.AsymmetricSignResponse) obj; boolean result = true; result = result && getSignature().equals(other.getSignature()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SIGNATURE_FIELD_NUMBER; hash = (53 * hash) + getSignature().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(com.google.cloud.kms.v1.AsymmetricSignResponse other) { if (other == com.google.cloud.kms.v1.AsymmetricSignResponse.getDefaultInstance()) return this; if (other.getSignature() != com.google.protobuf.ByteString.EMPTY) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * * * <pre> * The created signature. * </pre> * * <code>bytes signature = 1;</code> */ public Builder clearSignature() { signature_ = getDefaultInstance().getSignature(); onChanged(); return this; }
/** * Create a signature for a message using a private key stored on Cloud KMS * * Example keyName: * "projects/PROJECT_ID/locations/global/keyRings/RING_ID/cryptoKeys/KEY_ID/cryptoKeyVersions/1" */ public static byte[] signAsymmetric(String keyName, byte[] message) throws IOException, NoSuchAlgorithmException { // Create the Cloud KMS client. try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // Note: some key algorithms will require a different hash function // For example, EC_SIGN_P384_SHA384 requires SHA-384 byte[] messageHash = MessageDigest.getInstance("SHA-256").digest(message); AsymmetricSignRequest request = AsymmetricSignRequest.newBuilder() .setName(keyName) .setDigest(Digest.newBuilder().setSha256(ByteString.copyFrom(messageHash))) .build(); AsymmetricSignResponse response = client.asymmetricSign(request); return response.getSignature().toByteArray(); } } // [END kms_sign_asymmetric]
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.kms.v1.AsymmetricSignResponse)) { return super.equals(obj); } com.google.cloud.kms.v1.AsymmetricSignResponse other = (com.google.cloud.kms.v1.AsymmetricSignResponse) obj; boolean result = true; result = result && getSignature().equals(other.getSignature()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SIGNATURE_FIELD_NUMBER; hash = (53 * hash) + getSignature().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(com.google.cloud.kms.v1.AsymmetricSignResponse other) { if (other == com.google.cloud.kms.v1.AsymmetricSignResponse.getDefaultInstance()) return this; if (other.getSignature() != com.google.protobuf.ByteString.EMPTY) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * * * <pre> * The created signature. * </pre> * * <code>bytes signature = 1;</code> */ public Builder clearSignature() { signature_ = getDefaultInstance().getSignature(); onChanged(); return this; }