github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbcrypto/signature_prefix.go (about) 1 // Copyright 2018 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package kbcrypto 5 6 import "bytes" 7 8 type SignaturePrefix string 9 10 const ( 11 SignaturePrefixKBFS SignaturePrefix = "Keybase-KBFS-1" 12 SignaturePrefixSigchain SignaturePrefix = "Keybase-Sigchain-1" 13 SignaturePrefixSigchain3 SignaturePrefix = "Keybase-Sigchain-3" 14 SignaturePrefixChatAttachment SignaturePrefix = "Keybase-Chat-Attachment-1" 15 SignaturePrefixNIST SignaturePrefix = "Keybase-Auth-NIST-1" 16 SignaturePrefixTeamStore SignaturePrefix = "Keybase-TeamStore-1" 17 SignaturePrefixNISTWebAuthToken SignaturePrefix = "Keybase-Auth-NIST-Web-Token-1" 18 // Chat prefixes for each MessageBoxedVersion. 19 SignaturePrefixChatMBv1 SignaturePrefix = "Keybase-Chat-1" 20 SignaturePrefixChatMBv2 SignaturePrefix = "Keybase-Chat-2" 21 ) 22 23 func (p SignaturePrefix) IsWhitelisted() bool { 24 if p.IsWhitelistedTest() { 25 return true 26 } 27 switch p { 28 case SignaturePrefixKBFS, SignaturePrefixSigchain, SignaturePrefixChatAttachment, 29 SignaturePrefixNIST, SignaturePrefixChatMBv1, SignaturePrefixChatMBv2, 30 SignaturePrefixSigchain3, SignaturePrefixTeamStore: 31 return true 32 default: 33 return false 34 } 35 } 36 37 func (p SignaturePrefix) HasNullByte() bool { 38 return bytes.IndexByte([]byte(p), byte(0)) != -1 39 } 40 41 func (p SignaturePrefix) Prefix(msg []byte) []byte { 42 prefix := append([]byte(p), 0) 43 return append(prefix, msg...) 44 }