github.com/bigzoro/my_simplechain@v0.0.0-20240315012955-8ad0a2a29bb9/core/access_contoller/crypto/engine/init.go (about)

     1  /*
     2  Copyright (C) BABEC. All rights reserved.
     3  Copyright (C) THL A29 Limited, a Tencent company. All rights reserved.
     4  
     5  SPDX-License-Identifier: Apache-2.0
     6  */
     7  
     8  package engine
     9  
    10  import (
    11  	"fmt"
    12  
    13  	"chainmaker.org/chainmaker/common/v2/opencrypto"
    14  )
    15  
    16  var (
    17  	CryptoEngine = opencrypto.TjfocGM
    18  
    19  	// IsTls this flag is used to skip p2p tls, because p2p tls use the tjfoc, should be refactor! TODO
    20  	// IsTls这个标志用于跳过p2p tls,因为p2p tls使用tjfoc,应该被重构!待办事项
    21  	IsTls = false
    22  )
    23  
    24  func InitCryptoEngine(eng string, tls bool) {
    25  	CryptoEngine = opencrypto.ToEngineType(eng)
    26  	switch CryptoEngine {
    27  	case opencrypto.GmSSL, opencrypto.TjfocGM, opencrypto.TencentSM:
    28  		fmt.Printf("using crypto CryptoEngine = %s\n", eng)
    29  	default:
    30  		CryptoEngine = opencrypto.TjfocGM
    31  		fmt.Printf("using default crypto CryptoEngine = %s\n", string(opencrypto.TjfocGM))
    32  	}
    33  	IsTls = tls
    34  }