github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/internal/boring/rsa.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
     6  
     7  package boring
     8  
     9  import "C"
    10  import (
    11  	"github.com/shogo82148/std/crypto"
    12  	"github.com/shogo82148/std/hash"
    13  )
    14  
    15  func GenerateKeyRSA(bits int) (N, E, D, P, Q, Dp, Dq, Qinv BigInt, err error)
    16  
    17  type PublicKeyRSA struct {
    18  	// _key MUST NOT be accessed directly. Instead, use the withKey method.
    19  	_key *C.GO_RSA
    20  }
    21  
    22  func NewPublicKeyRSA(N, E BigInt) (*PublicKeyRSA, error)
    23  
    24  type PrivateKeyRSA struct {
    25  	// _key MUST NOT be accessed directly. Instead, use the withKey method.
    26  	_key *C.GO_RSA
    27  }
    28  
    29  func NewPrivateKeyRSA(N, E, D, P, Q, Dp, Dq, Qinv BigInt) (*PrivateKeyRSA, error)
    30  
    31  func DecryptRSAOAEP(h, mgfHash hash.Hash, priv *PrivateKeyRSA, ciphertext, label []byte) ([]byte, error)
    32  
    33  func EncryptRSAOAEP(h, mgfHash hash.Hash, pub *PublicKeyRSA, msg, label []byte) ([]byte, error)
    34  
    35  func DecryptRSAPKCS1(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error)
    36  
    37  func EncryptRSAPKCS1(pub *PublicKeyRSA, msg []byte) ([]byte, error)
    38  
    39  func DecryptRSANoPadding(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error)
    40  
    41  func EncryptRSANoPadding(pub *PublicKeyRSA, msg []byte) ([]byte, error)
    42  
    43  func SignRSAPSS(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte, saltLen int) ([]byte, error)
    44  
    45  func VerifyRSAPSS(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte, saltLen int) error
    46  
    47  func SignRSAPKCS1v15(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte) ([]byte, error)
    48  
    49  func VerifyRSAPKCS1v15(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte) error