github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/internal/boring/notboring.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !(boringcrypto && linux && (amd64 || arm64) && !android && !msan && cgo) 6 7 package boring 8 9 import ( 10 "github.com/shogo82148/std/crypto" 11 "github.com/shogo82148/std/crypto/cipher" 12 "github.com/shogo82148/std/hash" 13 ) 14 15 // Unreachable marks code that should be unreachable 16 // when BoringCrypto is in use. It is a no-op without BoringCrypto. 17 func Unreachable() 18 19 // UnreachableExceptTests marks code that should be unreachable 20 // when BoringCrypto is in use. It is a no-op without BoringCrypto. 21 func UnreachableExceptTests() 22 23 const RandReader = randReader(0) 24 25 func NewSHA1() hash.Hash 26 func NewSHA224() hash.Hash 27 func NewSHA256() hash.Hash 28 func NewSHA384() hash.Hash 29 func NewSHA512() hash.Hash 30 31 func SHA1([]byte) [20]byte 32 func SHA224([]byte) [28]byte 33 func SHA256([]byte) [32]byte 34 func SHA384([]byte) [48]byte 35 func SHA512([]byte) [64]byte 36 37 func NewHMAC(h func() hash.Hash, key []byte) hash.Hash 38 39 func NewAESCipher(key []byte) (cipher.Block, error) 40 func NewGCMTLS(cipher.Block) (cipher.AEAD, error) 41 42 type PublicKeyECDSA struct{ _ int } 43 type PrivateKeyECDSA struct{ _ int } 44 45 func GenerateKeyECDSA(curve string) (X, Y, D BigInt, err error) 46 47 func NewPrivateKeyECDSA(curve string, X, Y, D BigInt) (*PrivateKeyECDSA, error) 48 49 func NewPublicKeyECDSA(curve string, X, Y BigInt) (*PublicKeyECDSA, error) 50 51 func SignMarshalECDSA(priv *PrivateKeyECDSA, hash []byte) ([]byte, error) 52 53 func VerifyECDSA(pub *PublicKeyECDSA, hash []byte, sig []byte) bool 54 55 type PublicKeyRSA struct{ _ int } 56 type PrivateKeyRSA struct{ _ int } 57 58 func DecryptRSAOAEP(h, mgfHash hash.Hash, priv *PrivateKeyRSA, ciphertext, label []byte) ([]byte, error) 59 60 func DecryptRSAPKCS1(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error) 61 62 func DecryptRSANoPadding(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error) 63 64 func EncryptRSAOAEP(h, mgfHash hash.Hash, pub *PublicKeyRSA, msg, label []byte) ([]byte, error) 65 66 func EncryptRSAPKCS1(pub *PublicKeyRSA, msg []byte) ([]byte, error) 67 68 func EncryptRSANoPadding(pub *PublicKeyRSA, msg []byte) ([]byte, error) 69 70 func GenerateKeyRSA(bits int) (N, E, D, P, Q, Dp, Dq, Qinv BigInt, err error) 71 72 func NewPrivateKeyRSA(N, E, D, P, Q, Dp, Dq, Qinv BigInt) (*PrivateKeyRSA, error) 73 74 func NewPublicKeyRSA(N, E BigInt) (*PublicKeyRSA, error) 75 func SignRSAPKCS1v15(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte) ([]byte, error) 76 77 func SignRSAPSS(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte, saltLen int) ([]byte, error) 78 79 func VerifyRSAPKCS1v15(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte) error 80 81 func VerifyRSAPSS(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte, saltLen int) error 82 83 type PublicKeyECDH struct{} 84 type PrivateKeyECDH struct{} 85 86 func ECDH(*PrivateKeyECDH, *PublicKeyECDH) ([]byte, error) 87 func GenerateKeyECDH(string) (*PrivateKeyECDH, []byte, error) 88 func NewPrivateKeyECDH(string, []byte) (*PrivateKeyECDH, error) 89 func NewPublicKeyECDH(string, []byte) (*PublicKeyECDH, error) 90 func (*PublicKeyECDH) Bytes() []byte 91 func (*PrivateKeyECDH) PublicKey() (*PublicKeyECDH, error)