Categorygithub.com/ovh/kmip-go
repositorypackage
0.2.4
Repository: https://github.com/ovh/kmip-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

kmip-go

Go Reference license test Go Report Card

A go implementation of the KMIP protocol and client, supporting KMIP v1.0 to v1.4. See KMIP v1.4 protocole specification

This library is developped for and tested against OVHcloud KMS.

NOTE: THIS PROJECT IS CURRENTLY UNDER DEVELOPMENT AND SUBJECT TO BREAKING CHANGES.

Usage

Add it to your project by running

go get github.com/ovh/kmip-go@latest

and import required packages

import (
	"github.com/ovh/kmip-go"
	"github.com/ovh/kmip-go/kmipclient"
	"github.com/ovh/kmip-go/payloads"
	"github.com/ovh/kmip-go/ttlv"
)

Then you can connect to your KMS service:

const (
	ADDR = "eu-west-rbx.okms.ovh.net:5696"
	CA   = "ca.pem"
	CERT = "cert.pem"
	KEY  = "key.pem"
)

client, err := kmipclient.Dial(
	ADDR,
	// Optional if server's CA is known by the system
	// kmipclient.WithRootCAFile(CA),
	kmipclient.WithClientCertFiles(CERT, KEY),
	kmipclient.WithMiddlewares(
		kmipclient.CorrelationValueMiddleware(uuid.NewString),
		kmipclient.DebugMiddleware(os.Stdout, ttlv.MarshalXML),
	),
	// kmipclient.EnforceVersion(kmip.V1_4),
)
if err != nil {
	panic(err)
}
defer client.Close()
fmt.Println("Connected using KMIP version", client.Version())

You can then use the high level client helper methods to create and send requests to the server:

resp := client.Create().
	AES(256, kmip.Encrypt|kmip.Decrypt).
	WithName("my-key").
	MustExec()
fmt.Println("Created AES key with ID", resp.UniqueIdentifier)

Or alternatively if more flexibility is required, craft your kmip requests payloads:

request := payloads.CreateRequestPayload{
	ObjectType: kmip.ObjectTypeSymmetricKey,
	TemplateAttribute: kmip.TemplateAttribute{
		Attribute: []kmip.Attribute{
			{
				AttributeName:  kmip.AttributeNameCryptographicAlgorithm,
				AttributeValue: kmip.AES,
			}, {
				AttributeName:  kmip.AttributeNameCryptographicLength,
				AttributeValue: int32(256),
			}, {
				AttributeName: kmip.AttributeNameName,
				AttributeValue: kmip.Name{
					NameType:  kmip.UninterpretedTextString,
					NameValue: "another-key",
				},
			}, {
				AttributeName:  kmip.AttributeNameCryptographicUsageMask,
				AttributeValue: kmip.Encrypt | kmip.Decrypt,
			},
		},
	},
}

response, err := client.Request(context.Background(), &request)
if err != nil {
	panic(err)
}
id := response.(*payloads.CreateResponsePayload).UniqueIdentifier
fmt.Println("Created an AES key with ID", id)

You can also send batches of requests:

batchResponse, err := client.Batch(context.Background(), &request, &request)
if err != nil {
	panic(err)
}
id1 := batchResponse[0].ResponsePayload.(*payloads.CreateResponsePayload).UniqueIdentifier
id2 := batchResponse[1].ResponsePayload.(*payloads.CreateResponsePayload).UniqueIdentifier
fmt.Println("Created 2 AES keys with IDs", id1, id2)

And directly craft your request message with one or more payloads batched together:

msg := kmip.NewRequestMessage(client.Version(), &request, &request)
rMsg, err := client.Roundtrip(context.Background(), &msg)
if err != nil {
	panic(err)
}
id1 := rMsg.BatchItem[0].ResponsePayload.(*payloads.CreateResponsePayload).UniqueIdentifier
id2 := rMsg.BatchItem[1].ResponsePayload.(*payloads.CreateResponsePayload).UniqueIdentifier
fmt.Println("Created a 5th and 6th AES keys with IDs", id1, id2)

}

See examples for more possibilities.

Implementation status

Legend:

  • N/A : Not Applicable
  • βœ… : Fully compatible
  • ❌ : Not implemented or reviewed
  • 🚧 : Work in progress / Partially compatible
  • πŸ’€ : Deprecated

Messages

v1.0v1.1v1.2v1.3v1.4
Request Messageβœ…βœ…βœ…βœ…βœ…
Response Messageβœ…βœ…βœ…βœ…βœ…

Operations

Operationv1.0v1.1v1.2v1.3v1.4
Createβœ…βœ…βœ…βœ…βœ…
Create Key Pairβœ…βœ…βœ…βœ…βœ…
Registerβœ…βœ…βœ…βœ…βœ…
Re-keyβœ…βœ…βœ…βœ…βœ…
DeriveKey❌❌❌❌❌
Certify❌❌❌❌❌
Re-certify❌❌❌❌❌
Locateβœ…βœ…βœ…βœ…βœ…
Check❌❌❌❌❌
Getβœ…βœ…βœ…βœ…βœ…
Get Attributesβœ…βœ…βœ…βœ…βœ…
Get Attribute Listβœ…βœ…βœ…βœ…βœ…
Add Attributeβœ…βœ…βœ…βœ…βœ…
Modify Attributeβœ…βœ…βœ…βœ…βœ…
Delete Attributeβœ…βœ…βœ…βœ…βœ…
Obtain Leaseβœ…βœ…βœ…βœ…βœ…
Get Usage Allocationβœ…βœ…βœ…βœ…βœ…
Activateβœ…βœ…βœ…βœ…βœ…
Revokeβœ…βœ…βœ…βœ…βœ…
Destroyβœ…βœ…βœ…βœ…βœ…
Archiveβœ…βœ…βœ…βœ…βœ…
Recoverβœ…βœ…βœ…βœ…βœ…
Validate❌❌❌❌❌
Queryβœ…βœ…βœ…βœ…βœ…
Cancel❌❌❌❌❌
Poll❌❌❌❌❌
Notify❌❌❌❌❌
Put❌❌❌❌❌
DiscoverN/Aβœ…βœ…βœ…βœ…
Re-key Key PairN/A❌❌❌❌
EncryptN/AN/Aβœ…βœ…βœ…
DecryptN/AN/Aβœ…βœ…βœ…
SignN/AN/Aβœ…βœ…βœ…
Signature VerifyN/AN/Aβœ…βœ…βœ…
MACN/AN/A❌❌❌
MAC VerifyN/AN/A❌❌❌
RNG RetrieveN/AN/A❌❌❌
RNG SeedN/AN/A❌❌❌
HashN/AN/A❌❌❌
Create Split KeyN/AN/A❌❌❌
Join Split KeyN/AN/A❌❌❌
ExportN/AN/AN/AN/A❌
ImportN/AN/AN/AN/A❌

Managed Objects

Objectv1.0v1.1v1.2v1.3v1.4
Certificateβœ…βœ…βœ…βœ…βœ…
Symmetric Keyβœ…βœ…βœ…βœ…βœ…
Public Keyβœ…βœ…βœ…βœ…βœ…
Private Keyβœ…βœ…βœ…βœ…βœ…
Split Keyβœ…βœ…βœ…βœ…βœ…
Templateβœ…βœ…βœ…πŸ’€πŸ’€
Secret Dataβœ…βœ…βœ…βœ…βœ…
Opaque Objectβœ…βœ…βœ…βœ…βœ…
PGP KeyN/AN/Aβœ…βœ…βœ…

Base Objects

Objectv1.0v1.1v1.2v1.3v1.4
Attributeβœ…βœ…βœ…βœ…βœ…
Β Credentialβœ…βœ…βœ…βœ…βœ…
Β Key Blockβœ…βœ…βœ…βœ…βœ…
Key Valueβœ…βœ…βœ…βœ…βœ…
Key Wrapping Dataβœ…βœ…βœ…βœ…βœ…
Key Wrapping Specificationβœ…βœ…βœ…βœ…βœ…
Transparent Key Structures🚧🚧🚧🚧🚧
Template-Attribute Structuresβœ…βœ…βœ…βœ…βœ…
Extension InformationN/Aβœ…βœ…βœ…βœ…
DataN/AN/Aβœ…βœ…βœ…
Data LengthN/AN/A❌❌❌
Signature DataN/AN/Aβœ…βœ…βœ…
MAC DataN/AN/A❌❌❌
NonceN/AN/Aβœ…βœ…βœ…
Correlation ValueN/AN/AN/Aβœ…βœ…
Init IndicatorN/AN/AN/Aβœ…βœ…
Final IndicatorN/AN/AN/Aβœ…βœ…
RNG ParameterN/AN/AN/Aβœ…βœ…
Profile InformationN/AN/AN/Aβœ…βœ…
Validation InformationN/AN/AN/Aβœ…βœ…
Capability InformationN/AN/AN/Aβœ…βœ…
Authenticated Encryption Additional DataN/AN/AN/AN/Aβœ…
Authenticated Encryption TagN/AN/AN/AN/Aβœ…

Transparent Key Structures

Objectv1.0v1.1v1.2v1.3v1.4
Symmetric Keyβœ…βœ…βœ…βœ…βœ…
DSA Private/Public Key❌❌❌❌❌
RSA Private/Public Keyβœ…βœ…βœ…βœ…βœ…
DH Private/Public Key❌❌❌❌❌
ECDSA Private/Public Keyβœ…βœ…βœ…πŸ’€πŸ’€
ECDH Private/Public KeyβŒβŒβŒπŸ’€πŸ’€
ECMQV Private/PublicβŒβŒβŒπŸ’€πŸ’€
EC Private/PublicN/AN/AN/Aβœ…βœ…

Attributes

Attributev1.0v1.1v1.2v1.3v1.4
Unique Identifierβœ…βœ…βœ…βœ…βœ…
Nameβœ…βœ…βœ…βœ…βœ…
Object Typeβœ…βœ…βœ…βœ…βœ…
Cryptographic Algorithmβœ…βœ…βœ…βœ…βœ…
Cryptographic Lengthβœ…βœ…βœ…βœ…βœ…
Cryptographic Parametersβœ…βœ…βœ…βœ…βœ…
Cryptographic Domain Parametersβœ…βœ…βœ…βœ…βœ…
Certificate Typeβœ…βœ…βœ…βœ…βœ…
Certificate Identifierβœ…πŸ’€πŸ’€πŸ’€πŸ’€
Certificate Subjectβœ…πŸ’€πŸ’€πŸ’€πŸ’€
Certificate Issuerβœ…πŸ’€πŸ’€πŸ’€πŸ’€
Digestβœ…βœ…βœ…βœ…βœ…
Operation Policy Nameβœ…βœ…βœ…πŸ’€πŸ’€
Cryptographic Usage Maskβœ…βœ…βœ…βœ…βœ…
Lease Timeβœ…βœ…βœ…βœ…βœ…
Usage Limitsβœ…βœ…βœ…βœ…βœ…
Stateβœ…βœ…βœ…βœ…βœ…
Initial Dateβœ…βœ…βœ…βœ…βœ…
Activation Dateβœ…βœ…βœ…βœ…βœ…
Process Start Dateβœ…βœ…βœ…βœ…βœ…
Protect Stop Dateβœ…βœ…βœ…βœ…βœ…
Deactivation Dateβœ…βœ…βœ…βœ…βœ…
Destroy Dateβœ…βœ…βœ…βœ…βœ…
Compromise Occurrence Dateβœ…βœ…βœ…βœ…βœ…
Compromise Dateβœ…βœ…βœ…βœ…βœ…
Revocation Reasonβœ…βœ…βœ…βœ…βœ…
Archive Dateβœ…βœ…βœ…βœ…βœ…
Object Groupβœ…βœ…βœ…βœ…βœ…
Linkβœ…βœ…βœ…βœ…βœ…
Application Specific Informationβœ…βœ…βœ…βœ…βœ…
Contact Informationβœ…βœ…βœ…βœ…βœ…
Last Change Dateβœ…βœ…βœ…βœ…βœ…
Custom Attributeβœ…βœ…βœ…βœ…βœ…
Certificate LengthN/Aβœ…βœ…βœ…βœ…
X.509 Certificate IdentifierN/Aβœ…βœ…βœ…βœ…
X.509 Certificate SubjectN/Aβœ…βœ…βœ…βœ…
X.509 Certificate IssuerN/Aβœ…βœ…βœ…βœ…
Digital Signature AlgorithmN/Aβœ…βœ…βœ…βœ…
FreshN/Aβœ…βœ…βœ…βœ…
Alternative NameN/AN/Aβœ…βœ…βœ…
Key Value PresentN/AN/Aβœ…βœ…βœ…
Key Value LocationN/AN/Aβœ…βœ…βœ…
Original Creation DateN/AN/Aβœ…βœ…βœ…
Random Number GeneratorN/AN/AN/Aβœ…βœ…
PKCS#12 Friendly NameN/AN/AN/AN/Aβœ…
DescriptionN/AN/AN/AN/Aβœ…
CommentN/AN/AN/AN/Aβœ…
SensitiveN/AN/AN/AN/Aβœ…
Always SensitiveN/AN/AN/AN/Aβœ…
ExtractableN/AN/AN/AN/Aβœ…
Never ExtractableN/AN/AN/AN/Aβœ