Files
hotime/vendor/gitee.com/chunanyong/dm/security/zzh_windows.go
T
hoteas b43f968b6c feat(db): 添加对达梦数据库的支持
- 在应用程序中新增对达梦数据库(DM)的配置和连接支持
- 实现 SetDmDB 函数以配置达梦数据库连接
- 更新数据库操作逻辑,支持达梦特有的 SQL 语法和功能
- 在相关文件中添加达梦数据库的处理逻辑,包括表创建、数据插入和查询
- 更新 go.mod 和 go.sum 文件以引入达梦数据库驱动
- 增强文档,详细说明达梦数据库的配置和使用方法
2026-03-20 10:46:51 +08:00

84 lines
2.9 KiB
Go

/*
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* All rights reserved.
*/
package security
import (
"syscall"
)
var (
dmCipherEncryptDLL *syscall.LazyDLL
cipherGetCountProc *syscall.LazyProc
cipherGetInfoProc *syscall.LazyProc
cipherEncryptInitProc *syscall.LazyProc
cipherGetCipherTextSizeProc *syscall.LazyProc
cipherEncryptProc *syscall.LazyProc
cipherCleanupProc *syscall.LazyProc
cipherDecryptInitProc *syscall.LazyProc
cipherDecryptProc *syscall.LazyProc
)
func initThirdPartCipher(cipherPath string) error {
dmCipherEncryptDLL = syscall.NewLazyDLL(cipherPath)
if err := dmCipherEncryptDLL.Load(); err != nil {
return err
}
cipherGetCountProc = dmCipherEncryptDLL.NewProc("cipher_get_count")
cipherGetInfoProc = dmCipherEncryptDLL.NewProc("cipher_get_info")
cipherEncryptInitProc = dmCipherEncryptDLL.NewProc("cipher_encrypt_init")
cipherGetCipherTextSizeProc = dmCipherEncryptDLL.NewProc("cipher_get_cipher_text_size")
cipherEncryptProc = dmCipherEncryptDLL.NewProc("cipher_encrypt")
cipherCleanupProc = dmCipherEncryptDLL.NewProc("cipher_cleanup")
cipherDecryptInitProc = dmCipherEncryptDLL.NewProc("cipher_decrypt_init")
cipherDecryptProc = dmCipherEncryptDLL.NewProc("cipher_decrypt")
return nil
}
func cipherGetCount() int {
ret, _, _ := cipherGetCountProc.Call()
return int(ret)
}
func cipherGetInfo(seqno, cipherId, cipherName, _type, blkSize, khSIze uintptr) {
ret, _, _ := cipherGetInfoProc.Call(seqno, cipherId, cipherName, _type, blkSize, khSIze)
if ret == 0 {
panic("ThirdPartyCipher: call cipher_get_info failed")
}
}
func cipherEncryptInit(cipherId, key, keySize, cipherPara uintptr) {
ret, _, _ := cipherEncryptInitProc.Call(cipherId, key, keySize, cipherPara)
if ret == 0 {
panic("ThirdPartyCipher: call cipher_encrypt_init failed")
}
}
func cipherGetCipherTextSize(cipherId, cipherPara, plainTextSize uintptr) uintptr {
ciphertextLen, _, _ := cipherGetCipherTextSizeProc.Call(cipherId, cipherPara, plainTextSize)
return ciphertextLen
}
func cipherEncrypt(cipherId, cipherPara, plainText, plainTextSize, cipherText, cipherTextBufSize uintptr) uintptr {
ret, _, _ := cipherEncryptProc.Call(cipherId, cipherPara, plainText, plainTextSize, cipherText, cipherTextBufSize)
return ret
}
func cipherClean(cipherId, cipherPara uintptr) {
_, _, _ = cipherCleanupProc.Call(cipherId, cipherPara)
}
func cipherDecryptInit(cipherId, key, keySize, cipherPara uintptr) {
ret, _, _ := cipherDecryptInitProc.Call(cipherId, key, keySize, cipherPara)
if ret == 0 {
panic("ThirdPartyCipher: call cipher_decrypt_init failed")
}
}
func cipherDecrypt(cipherId, cipherPara, cipherText, cipherTextSize, plainText, plainTextBufSize uintptr) uintptr {
ret, _, _ := cipherDecryptProc.Call(cipherId, cipherPara, cipherText, cipherTextSize, plainText, plainTextBufSize)
return ret
}