gojwe

package module
v0.0.0-...-be41449 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2014 License: BSD-2-Clause Imports: 20 Imported by: 6

README

gojwe

Golang implementation of JWE decryption

Contact

@_boblan_
https://github.com/mendsley/gojwe

License

Copyright 2014 Matthew Endsley

This project is governed by the BSD 2-clause license. For details see the file titled LICENSE in the project root folder.

Using

Simply add the following import import "github.com/mendsley/gojwe"

Documentation

See http://godoc.org/github.com/mendsley/gojwe

Documentation

Index

Constants

View Source
const (
	ALG_RSA_OAEP     = Algorithm("RSA-OAEP")
	ALG_RSA_OAEP_256 = Algorithm("RSA-OAEP-256")
	ALG_RSA1_5       = Algorithm("RSA1_5")
	ALG_A128KW       = Algorithm("A128KW")
	ALG_A256KW       = Algorithm("A256KW")
)
View Source
const (
	ENC_A128CBC_HS256_v7 = EncryptionMethod("A128CBC+HS256")
	ENC_A256CBC_HS512_v7 = EncryptionMethod("A256CBC+H512")
	ENC_A128CBC_HS256    = EncryptionMethod("A128CBC-HS256")
	ENC_A256CBC_HS512    = EncryptionMethod("A256CBC-HS512")
	ENC_A128GCM          = EncryptionMethod("A128GCM")
	ENC_A256GCM          = EncryptionMethod("A256GCM")
)

Variables

This section is empty.

Functions

func AesKeyUnwrap

func AesKeyUnwrap(key, cipherText []byte) ([]byte, error)

Unwrap a key using the AES Key Wrap Algorithm

See: RFC 3394

func AesKeyWrap

func AesKeyWrap(key, plainText []byte) ([]byte, error)

Wrap a key using the AES Key Wrap Algorithm

See: RFC 3394

func VerifyAndDecrypt

func VerifyAndDecrypt(jwe string, kp KeyProvider) ([]byte, error)

Verify and decrypt a JWE object

func VerifyAndDecryptDraft7

func VerifyAndDecryptDraft7(jwe string, kp KeyProvider) ([]byte, error)

Types

type Algorithm

type Algorithm string

type EncryptionMethod

type EncryptionMethod string
type Header struct {
	Alg Algorithm        `json:"alg"`
	Enc EncryptionMethod `json:"enc"`
	Zip string           `json:"zip"`
	Jku string           `json:"jku,omitempty"`
	Jwk string           `json:"jwk,omitempty"`
	X5u string           `json:"x5u,omitempty"`
	X5t string           `json:"x5t,omitempty"`
	X5c string           `json:"x5c,omitempty"`
	Kid string           `json:"kid,omitempty"`
}

The JWE header

type KeyProvider

type KeyProvider interface {
	GetKey(header Header) (crypto.PrivateKey, error)
}

interface to retrieve the private key needed to decrypt the JWE

func ProviderFromKey

func ProviderFromKey(key crypto.PrivateKey) KeyProvider

convert a single key into a provider

Jump to

Keyboard shortcuts

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