From 25d9ec299496ca46c90dadcd5c806fca2190b26a Mon Sep 17 00:00:00 2001 From: Ross Kinder Date: Wed, 23 Dec 2015 14:26:26 -0500 Subject: [PATCH] update readme --- README.md | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 33047dd..9f67775 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,53 @@ # go-xmlsec -[![Build Status](https://travis-ci.org/crewjam/go-xmlsec.svg?branch=master)](https://travis-ci.org/crewjam/go-xmlsec) +[![](https://godoc.org/github.com/crewjam/go-xmlsec?status.png)](http://godoc.org/github.com/crewjam/go-xmlsec) [![Build Status](https://travis-ci.org/crewjam/go-xmlsec.svg?branch=master)](https://travis-ci.org/crewjam/go-xmlsec) -[![](https://godoc.org/github.com/crewjam/go-xmlsec?status.png)](http://godoc.org/github.com/crewjam/go-xmlsec) +A partial wrapper for [xmlsec](https://www.aleksey.com/xmlsec). -A (partial) wrapper for [xmlsec](https://www.aleksey.com/xmlsec). +As seems to be the case for many things in the XMLish world, the xmldsig and xmlenc standards are more complex that may be nessesary. This library is as general as I could reasonably make it with an eye towards supporting the parts of the standards that are needed to support a SAML implementation. If there are missing bits you feel you need, please raise an issue or submit a pull request. -# Signing (xmldsig) +# Examples -## Signing Example +## Signing key, _ := ioutil.ReadFile("saml.key") doc, _ := ioutil.ReadAll(os.Stdin) - signedDoc, err := xmldsig.Sign(key, doc, xmldsig.Options{}) + signedDoc, err := Sign(key, doc, SignatureOptions{}) os.Stdout.Write(signedDoc) -## Verifying Example +## Verifying key, _ := ioutil.ReadFile("saml.crt") doc, _ := ioutil.ReadAll(os.Stdin) - err := xmldsig.Verify(key, doc, xmldsig.Options{}) + err := xmldsig.Verify(key, doc, SignatureOptions{}) if err == xmldsig.ErrVerificationFailed { os.Exit(1) } -## Decrypting Example +## Decrypting key, _ := ioutil.ReadFile("saml.key") doc, _ := ioutil.ReadAll(os.Stdin) - plaintextDoc, err := xmlenc.Decrypt(key, doc) + plaintextDoc, err := Decrypt(key, doc) os.Stdout.Write(plaintextDoc) + +## Encrypting + + key, _ := ioutil.ReadFile("saml.crt") + doc, _ := ioutil.ReadAll(os.Stdin) + encryptedDoc, err := Encrypt(key, doc, EncryptOptions{}) + os.Stdout.Write(encryptedDoc) + +# Install + +This package uses cgo to wrap libxmlsec. As such, you'll need libxmlsec headers and a C compiler to make it work. On linux, this might look like: + + $ apt-get install libxml2-dev libxmlsec1-dev + $ go get github.com/crewjam/go-xmlsec + +On Mac with homebrew, this might look like: + + $ brew install libxmlsec1 libxml2 + $ go get github.com/crewjam/go-xmlsec + +