xmlsec

package
v0.0.0-...-8c877c3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2016 License: BSD-2-Clause Imports: 8 Imported by: 1

Documentation

Overview

Dervied from:

https://github.com/crewjam/go-xmlsec
https://github.com/RobotsAndPencils/go-saml

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipher string, privateKey string) (string, error)

Decrypt decrypt an xml cipher value with a third-party public key

func Encrypt

func Encrypt(plaintext string, publicKey string) (string, error)

Encrypt encrypt an xml plaintext value with a private key

func SignRaw

func SignRaw(xml string, privateKey string) (string, error)

SignRaw sign plain xml

func SignRequest

func SignRequest(xml string, privateKey string) (string, error)

SignRequest sign a SAML 2.0 AuthnRequest

func SignResponse

func SignResponse(xml string, privateKey string) (string, error)

SignResponse sign a SAML 2.0 Response

func VerifyAssertionSignature

func VerifyAssertionSignature(xml string, publicCert string) error

VerifyResponseSignature verify signature of a SAML 2.0 Assertion document

func VerifyRequestSignature

func VerifyRequestSignature(xml string, publicCert string) error

VerifyRequestSignature verify signature of a SAML 2.0 AuthnRequest document

func VerifyResponseSignature

func VerifyResponseSignature(xml string, publicCert string) error

VerifyResponseSignature verify signature of a SAML 2.0 Response document

Types

type Method

type Method struct {
	Algorithm string `xml:",attr"`
}

Method is part of Signature.

type Reference

type Reference struct {
	URI                 string   `xml:"URI,attr"`
	ReferenceTransforms []Method `xml:"Transforms>Transform"`
	DigestMethod        Method   `xml:"DigestMethod"`
	DigestValue         string   `xml:"DigestValue"`
}

type Signature

type Signature struct {
	XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`

	Id              string             `xml:"Id,attr"`
	SignedInfo      SignedInfo         `xml:"SignedInfo"`
	SignatureValue  string             `xml:"SignatureValue"`
	KeyName         string             `xml:"KeyInfo>KeyName,omitempty"`
	X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"`
}

Signature is a model for the Signature object specified by XMLDSIG. This is convenience object when constructing XML that you'd like to sign. For example:

type Foo struct {
   Stuff string
   Signature Signature
}

f := Foo{Suff: "hello"}
f.Signature = DefaultSignature()
buf, _ := xml.Marshal(f)
buf, _ = Sign(key, buf)

func DefaultSignature

func DefaultSignature(pemEncodedPublicKey string) Signature

DefaultSignature returns a Signature struct that uses the default c14n and SHA1 settings.

type SignatureX509Data

type SignatureX509Data struct {
	X509Certificate string `xml:"X509Certificate,omitempty"`
}

SignatureX509Data represents the <X509Data> element of <Signature>

type SignedInfo

type SignedInfo struct {
	CanonicalizationMethod Method    `xml:"CanonicalizationMethod"`
	SignatureMethod        Method    `xml:"SignatureMethod"`
	Reference              Reference `xml:"Reference"`
}

Jump to

Keyboard shortcuts

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