https://github.com/atotto/cloudkms
Google Cloud KMS golang signer
https://github.com/atotto/cloudkms
google-cloud-kms google-kms
Last synced: 5 months ago
JSON representation
Google Cloud KMS golang signer
- Host: GitHub
- URL: https://github.com/atotto/cloudkms
- Owner: atotto
- License: mit
- Created: 2019-03-13T10:17:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T23:32:10.000Z (almost 3 years ago)
- Last Synced: 2025-03-23T15:17:44.238Z (9 months ago)
- Topics: google-cloud-kms, google-kms
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloudkms
cloud kms signer
example:
```go
ctx := context.Background()
client, err := kms.NewKeyManagementClient(ctx)
if err != nil {
log.Fatal(err)
}
signer, err := cloudkms.NewSigner(client, "projects//locations//keyRings//cryptoKeys//cryptoKeyVersions/")
if err != nil {
log.Fatal(err)
}
rootCa := &x509.Certificate{
SerialNumber: big.NewInt(1),
// TODO: fill
}
data, _ := x509.CreateCertificate(rand.Reader, rootCa, rootCa, signer.Public(), signer)
cert, _ := x509.ParseCertificate(data)
// Sign
msg := "hello, world"
h := signer.HashFunc().New()
h.Write([]byte(msg))
digest := h.Sum(nil)
signature, err := signer.Sign(rand.Reader, digest, crypto.SHA256)
if err != nil {
log.Fatal(err)
}
// Verify Signature
if err := cert.CheckSignature(cert.SignatureAlgorithm, []byte(msg), signature); err != nil {
log.Fatal(err)
}
```