// Converts Protobuf hashtype to crypto.SignerOpts
Converts Protobuf hashtype to crypto.SignerOpts
// Converts Protobuf hashtype to crypto . SignerOpts
func convertHash(hashtype ci.HashFunction, pssOpts *ci.PSSOptions) (crypto.SignerOpts, error) {
	var hash crypto.Hash
	var len int
	switch hashtype {
	case ci.HashFunction_SHA256:
		hash = crypto.SHA256
		len = 32
	case ci.HashFunction_SHA384:
		hash = crypto.SHA384
		len = 48
	case ci.HashFunction_SHA512:
		len = 64
		hash = crypto.SHA512
	default:
		return  crypto.SHA512, fmt.Errorf("[cmcd] Hash function not implemented: %v", hashtype)
	}
	if pssOpts != nil {
		saltlen := int(pssOpts.SaltLength)
		if saltlen < 0 {
			log.Warning("Signature Options: Adapted RSA PSS Salt length to length of hash: ", len)
			saltlen = len
		}
		return &rsa.PSSOptions{SaltLength: saltlen, Hash: hash}, nil
	}
	return hash, nil
}
func convertHash ( hashtype ci . HashFunction , pssOpts * ci . PSSOptions ) ( crypto . SignerOpts , error ) { var hash crypto . Hash var len int switch hashtype { case ci . HashFunction_SHA256 : hash = crypto . SHA256 len = 32 case ci . HashFunction_SHA384 : hash = crypto . SHA384 len = 48 case ci . HashFunction_SHA512 : len = 64 hash = crypto . SHA512 default : return crypto . SHA512 , fmt . Errorf ( " " , hashtype ) } if pssOpts != nil { saltlen := int ( pssOpts . SaltLength ) if saltlen < 0 { log . Warning ( " " , len ) saltlen = len } return & rsa . PSSOptions { SaltLength : saltlen , Hash : hash } , nil } return hash , nil }
Converts Protobuf hashtype to crypto.SignerOpts
Converts Protobuf hashtype to crypto . SignerOpts
// go-attestation / go-tpm does not allow -1 as definition for length of hash