keywrap

package module
v1.0.1-0...-6298bed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2017 License: MPL-2.0 Imports: 0 Imported by: 0

README

��PACKAGE DOCUMENTATION

package keywrap
    import "keywrap"

    Package keywrap provides a set of algorithms to wrap/unwrap keywrap with
    an encryption key.

    Currently, the following algorithms are implemented:

    - RFC3394: AES Key Wrap Algorithm

    Example:
	var wrapper = rfc3394.NewWrapper()
	kek, err := hex.DecodeString("000102030405060708090A0B0C0D0E0F")
	wrappedKey, err := hex.DecodeString("1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5")
	key, err := wrapper.Unwrap(kek, wrappedKey)
	if err != nil {
	    panic(err)
	}
	var hexKey = strings.ToUpper(hex.EncodeToString(key))
	fmt.Println(hexKey)
	// Output: 00112233445566778899AABBCCDDEEFF


    Example:
	var wrapper = rfc3394.NewWrapper()
	kek, err := hex.DecodeString("000102030405060708090A0B0C0D0E0F")
	key, err := hex.DecodeString("00112233445566778899AABBCCDDEEFF")
	wrappedKey, err := wrapper.Wrap(kek, key)
	if err != nil {
	    panic(err)
	}
	var hexWrappedKey = strings.ToUpper(hex.EncodeToString(wrappedKey))
	fmt.Println(hexWrappedKey)
	// Output: 1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5

TYPES

type KeyWrapper interface {
    Wrap(kek []byte, text []byte) ([]byte, error)
    Unwrap(kek []byte, cypheredText []byte) ([]byte, error)
}
    KeyWrapper defines the methods to wrap and unwrap a key with an
    encryption key whatever is the underlying algorithm

SUBDIRECTORIES

	rfc3394

Documentation

Overview

Package keywrap provides a set of algorithms to wrap/unwrap keywrap with an encryption key.

Currently, the following algorithms are implemented:

- RFC3394: AES Key Wrap Algorithm

Example (Unwrap)
package main

import (
	"encoding/hex"
	"fmt"
	"strings"

	"github.com/gleroi/keywrap/rfc3394"
)

func main() {
	var wrapper = rfc3394.NewWrapper()
	kek, err := hex.DecodeString("000102030405060708090A0B0C0D0E0F")
	wrappedKey, err := hex.DecodeString("1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5")
	key, err := wrapper.Unwrap(kek, wrappedKey)
	if err != nil {
		panic(err)
	}
	var hexKey = strings.ToUpper(hex.EncodeToString(key))
	fmt.Println(hexKey)
}
Output:

00112233445566778899AABBCCDDEEFF
Example (Wrap)
package main

import (
	"encoding/hex"
	"fmt"
	"strings"

	"github.com/gleroi/keywrap/rfc3394"
)

func main() {
	var wrapper = rfc3394.NewWrapper()
	kek, err := hex.DecodeString("000102030405060708090A0B0C0D0E0F")
	key, err := hex.DecodeString("00112233445566778899AABBCCDDEEFF")
	wrappedKey, err := wrapper.Wrap(kek, key)
	if err != nil {
		panic(err)
	}
	var hexWrappedKey = strings.ToUpper(hex.EncodeToString(wrappedKey))
	fmt.Println(hexWrappedKey)
}
Output:

1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyWrapper

type KeyWrapper interface {
	Wrap(kek []byte, text []byte) ([]byte, error)
	Unwrap(kek []byte, cypheredText []byte) ([]byte, error)
}

KeyWrapper defines the methods to wrap and unwrap a key with an encryption key whatever is the underlying algorithm

Directories

Path Synopsis
cmd
Package rfc3394 provides the AES Key Wrap algorithm as described in RFC3394
Package rfc3394 provides the AES Key Wrap algorithm as described in RFC3394

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL