diff options
author | Wim <wim@42.be> | 2018-08-06 21:47:05 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-08-06 21:47:05 +0200 |
commit | 51062863a5c34d81e296cf15c61140911037cf3b (patch) | |
tree | 9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/xordataexchange/crypt/encoding | |
parent | 4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff) | |
download | matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2 matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip |
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/xordataexchange/crypt/encoding')
-rw-r--r-- | vendor/github.com/xordataexchange/crypt/encoding/secconf/LICENSE | 9 | ||||
-rw-r--r-- | vendor/github.com/xordataexchange/crypt/encoding/secconf/secconf.go | 68 |
2 files changed, 0 insertions, 77 deletions
diff --git a/vendor/github.com/xordataexchange/crypt/encoding/secconf/LICENSE b/vendor/github.com/xordataexchange/crypt/encoding/secconf/LICENSE deleted file mode 100644 index 43846317..00000000 --- a/vendor/github.com/xordataexchange/crypt/encoding/secconf/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 XOR Data Exchange, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/xordataexchange/crypt/encoding/secconf/secconf.go b/vendor/github.com/xordataexchange/crypt/encoding/secconf/secconf.go deleted file mode 100644 index 6e94565d..00000000 --- a/vendor/github.com/xordataexchange/crypt/encoding/secconf/secconf.go +++ /dev/null @@ -1,68 +0,0 @@ -// Package secconf implements secconf encoding as specified in the following -// format: -// -// base64(gpg(gzip(data))) -// -package secconf - -import ( - "bytes" - "compress/gzip" - "encoding/base64" - "io" - "io/ioutil" - - "golang.org/x/crypto/openpgp" -) - -// Deocde decodes data using the secconf codec. -func Decode(data []byte, secertKeyring io.Reader) ([]byte, error) { - decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewBuffer(data)) - entityList, err := openpgp.ReadArmoredKeyRing(secertKeyring) - if err != nil { - return nil, err - } - md, err := openpgp.ReadMessage(decoder, entityList, nil, nil) - if err != nil { - return nil, err - } - gzReader, err := gzip.NewReader(md.UnverifiedBody) - if err != nil { - return nil, err - } - defer gzReader.Close() - bytes, err := ioutil.ReadAll(gzReader) - if err != nil { - return nil, err - } - return bytes, nil -} - -// Encode encodes data to a base64 encoded using the secconf codec. -// data is encrypted with all public keys found in the supplied keyring. -func Encode(data []byte, keyring io.Reader) ([]byte, error) { - entityList, err := openpgp.ReadArmoredKeyRing(keyring) - if err != nil { - return nil, err - } - buffer := new(bytes.Buffer) - encoder := base64.NewEncoder(base64.StdEncoding, buffer) - pgpWriter, err := openpgp.Encrypt(encoder, entityList, nil, nil, nil) - if err != nil { - return nil, err - } - gzWriter := gzip.NewWriter(pgpWriter) - if _, err := gzWriter.Write(data); err != nil { - return nil, err - } - if err := gzWriter.Close(); err != nil { - return nil, err - } - if err := pgpWriter.Close(); err != nil { - return nil, err - } - if err := encoder.Close(); err != nil { - return nil, err - } - return buffer.Bytes(), nil -} |