Source File
pss.go
Belonging Package
crypto/rsa
package rsa
import (
)
[] = 0x01
copy([+1:], )
mgf1XOR(, , )
[0] &= 0xff >> (8* - )
[-1] = 0xbc
return , nil
}
:= .Size()
if == PSSSaltLengthEqualsHash {
=
}
:= ( + 7) / 8
if != len() {
return errors.New("rsa: internal error: inconsistent length")
}
if != len() {
return ErrVerification
}
if < ++2 {
return ErrVerification
}
if [-1] != 0xbc {
return ErrVerification
}
:= [:--1]
:= [--1 : -1]
var byte = 0xff >> (8* - )
if [0] & ^ != 0 {
return ErrVerification
}
mgf1XOR(, , )
[0] &=
if == PSSSaltLengthAuto {
:= bytes.IndexByte(, 0x01)
if < 0 {
return ErrVerification
}
= len() - - 1
}
:= - - - 2
for , := range [:] {
if != 0x00 {
return ErrVerification
}
}
if [] != 0x01 {
return ErrVerification
}
:= [len()-:]
if !bytes.Equal(, ) { // TODO: constant time?
return ErrVerification
}
return nil
}
PSSSaltLengthEqualsHash = -1
)
func ( *PSSOptions) () crypto.Hash {
return .Hash
}
func ( *PSSOptions) () int {
if == nil {
return PSSSaltLengthAuto
}
return .SaltLength
}
func ( io.Reader, *PrivateKey, crypto.Hash, []byte, *PSSOptions) ([]byte, error) {
if != nil && .Hash != 0 {
= .Hash
}
:= .saltLength()
switch {
case PSSSaltLengthAuto:
= .Size() - 2 - .Size()
case PSSSaltLengthEqualsHash:
= .Size()
}
:= make([]byte, )
if , := io.ReadFull(, ); != nil {
return nil,
}
return signPSSWithSalt(, , , , )
}
func ( *PublicKey, crypto.Hash, []byte, []byte, *PSSOptions) error {
if len() != .Size() {
return ErrVerification
}
:= new(big.Int).SetBytes()
:= encrypt(new(big.Int), , )
:= .N.BitLen() - 1
:= ( + 7) / 8
if .BitLen() > *8 {
return ErrVerification
}
:= .FillBytes(make([]byte, ))
return emsaPSSVerify(, , , .saltLength(), .New())
![]() |
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. |