Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atotto/cloudkms
Google Cloud KMS golang signer
https://github.com/atotto/cloudkms
google-cloud-kms google-kms
Last synced: 24 days 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T23:32:10.000Z (over 1 year ago)
- Last Synced: 2024-05-02T01:30:28.477Z (6 months ago)
- Topics: google-cloud-kms, google-kms
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 3
- 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)
}
```