Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
}
```