diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-11-03 00:22:53 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-11-03 16:32:57 +0800 |
commit | bad0de0dcbae82d96f68d1eec1701042d5dfa985 (patch) | |
tree | 7b6e585f47a0c4bb9f6e3a17d549ca1d0ddbd642 /vendor/golang.org/x/crypto/openpgp/canonical_text.go | |
parent | 3b62c145f8d699767e13770d1bb21d07c2ba9b46 (diff) | |
download | go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.tar go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.tar.gz go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.tar.bz2 go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.tar.lz go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.tar.xz go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.tar.zst go-tangerine-bad0de0dcbae82d96f68d1eec1701042d5dfa985.zip |
vendor: pull in azure sdk and openpgp signer
Diffstat (limited to 'vendor/golang.org/x/crypto/openpgp/canonical_text.go')
-rw-r--r-- | vendor/golang.org/x/crypto/openpgp/canonical_text.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/golang.org/x/crypto/openpgp/canonical_text.go b/vendor/golang.org/x/crypto/openpgp/canonical_text.go new file mode 100644 index 000000000..e601e389f --- /dev/null +++ b/vendor/golang.org/x/crypto/openpgp/canonical_text.go @@ -0,0 +1,59 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package openpgp + +import "hash" + +// NewCanonicalTextHash reformats text written to it into the canonical +// form and then applies the hash h. See RFC 4880, section 5.2.1. +func NewCanonicalTextHash(h hash.Hash) hash.Hash { + return &canonicalTextHash{h, 0} +} + +type canonicalTextHash struct { + h hash.Hash + s int +} + +var newline = []byte{'\r', '\n'} + +func (cth *canonicalTextHash) Write(buf []byte) (int, error) { + start := 0 + + for i, c := range buf { + switch cth.s { + case 0: + if c == '\r' { + cth.s = 1 + } else if c == '\n' { + cth.h.Write(buf[start:i]) + cth.h.Write(newline) + start = i + 1 + } + case 1: + cth.s = 0 + } + } + + cth.h.Write(buf[start:]) + return len(buf), nil +} + +func (cth *canonicalTextHash) Sum(in []byte) []byte { + return cth.h.Sum(in) +} + +func (cth *canonicalTextHash) Reset() { + cth.h.Reset() + cth.s = 0 +} + +func (cth *canonicalTextHash) Size() int { + return cth.h.Size() +} + +func (cth *canonicalTextHash) BlockSize() int { + return cth.h.BlockSize() +} |