Source File
s2k.go
Belonging Package
golang.org/x/crypto/openpgp/s2k
package s2k // import "golang.org/x/crypto/openpgp/s2k"
import (
)
case < 1024:
= 1024
case > 65011712:
= 65011712
}
return encodeCount()
}
func ( []byte, hash.Hash, []byte, []byte, int) {
:= make([]byte, len()+len())
copy(, )
copy([len():], )
if < len() {
= len()
}
:= 0
var []byte
for := 0; < len(); ++ {
.Reset()
for := 0; < ; ++ {
.Write(zero[:])
}
:= 0
for < {
if +len() > {
:= -
.Write([:])
=
} else {
.Write()
+= len()
}
}
= .Sum([:0])
:= copy([:], )
+=
}
}
func ( io.Reader) ( func(, []byte), error) {
var [9]byte
_, = io.ReadFull(, [:2])
if != nil {
return
}
, := HashIdToHash([1])
if ! {
return nil, errors.UnsupportedError("hash for S2K function: " + strconv.Itoa(int([1])))
}
if !.Available() {
return nil, errors.UnsupportedError("hash not available: " + strconv.Itoa(int()))
}
:= .New()
switch [0] {
case 0:
:= func(, []byte) {
Simple(, , )
}
return , nil
case 1:
_, = io.ReadFull(, [:8])
if != nil {
return
}
:= func(, []byte) {
Salted(, , , [:8])
}
return , nil
case 3:
_, = io.ReadFull(, [:9])
if != nil {
return
}
:= decodeCount([8])
:= func(, []byte) {
Iterated(, , , [:8], )
}
return , nil
}
return nil, errors.UnsupportedError("S2K function")
}
func ( io.Writer, []byte, io.Reader, []byte, *Config) error {
var [11]byte
[0] = 3 /* iterated and salted */
[1], _ = HashToHashId(.hash())
:= [2:10]
if , := io.ReadFull(, ); != nil {
return
}
:= .encodedCount()
:= decodeCount()
[10] =
if , := .Write([:]); != nil {
return
}
Iterated(, .hash().New(), , , )
return nil
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |