Documentation
¶
Overview ¶
Copyright Hyperledger-TWGC All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
writed by Zhiwei Yan, 2020 Oct
Index ¶
- Constants
- Variables
- func CheckPasswd(user, password, encryptPasswd string) (res bool)
- func EncryptPasswd(username, password string) (data string)
- func GCMDecrypt(K, IV, C, A []byte) (P, _T []byte)
- func GCMEncrypt(K, IV, P, A []byte) (C, T []byte)
- func GHASH(H []byte, A []byte, C []byte) (X []byte)
- func GetH(key []byte) (H []byte)
- func GetY0(H, IV []byte) []byte
- func MSB(len int, S []byte) (out []byte)
- func New() hash.Hash
- func NewCipher(key []byte) (cipher.Block, error)
- func Rightshift(V []byte)
- func SetIV(iv []byte) error
- func Sm3Sum(data []byte) []byte
- func Sm4CFB(key []byte, in []byte, mode bool) (out []byte, err error)
- func Sm4Cbc(key []byte, in []byte, mode bool) (out []byte, err error)
- func Sm4Ecb(key []byte, in []byte, mode bool) (out []byte, err error)
- func Sm4GCM(key []byte, IV, in, A []byte, mode bool) ([]byte, []byte, error)
- func Sm4OFB(key []byte, in []byte, mode bool) (out []byte, err error)
- func WriteKeyToPem(key SM4Key, pwd []byte) ([]byte, error)
- func WriteKeyToPemFile(FileName string, key SM4Key, pwd []byte) error
- type SM3
- type SM4Key
- type Sm4Cipher
Constants ¶
const BlockSize = 16
Variables ¶
var IV = make([]byte, BlockSize)
Functions ¶
func CheckPasswd ¶
CheckPasswd @description: 验证密码 @param: user string 用户名。这里以用户名作为key @param: password string 原始明文密码 @param: encryptPasswd string 加密后的密码(数据库中的密码) @author: GJing @email: gjing1st@gmail.com @date: 2022/12/27 8:58 @success:
func EncryptPasswd ¶
EncryptPasswd @description: 加密密码。使用用户名作为key进行加密 @param: username string 用户名。这里以用户名作为key @param: password string 原始明文密码 @author: GJing @email: gjing1st@gmail.com @date: 2022/12/26 20:24 @success:
func GCMDecrypt ¶
func GCMEncrypt ¶
func Rightshift ¶
func Rightshift(V []byte)
func Sm4CFB ¶
密码反馈模式(Cipher FeedBack (CFB)) https://blog.csdn.net/zy_strive_2012/article/details/102520356 https://blog.csdn.net/sinat_23338865/article/details/72869841
func Sm4OFB ¶
输出反馈模式(Output feedback, OFB) https://blog.csdn.net/chengqiuming/article/details/82390910 https://blog.csdn.net/sinat_23338865/article/details/72869841
func WriteKeyToPem ¶
WriteKeyToPem will convert SM4Key to PEM format data and return it.
Types ¶
type SM3 ¶
type SM3 struct {
// contains filtered or unexported fields
}
func (*SM3) BlockSize ¶
BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.
func (*SM3) Reset ¶
func (sm3 *SM3) Reset()
Reset clears the internal state by zeroing bytes in the state buffer. This can be skipped for a newly-created hash state; the default zero-allocated state is correct.
type SM4Key ¶
type SM4Key []byte
func ReadKeyFromPem ¶
ReadKeyFromPem will return SM4Key from PEM format data.