Skip to content

Instantly share code, notes, and snippets.

View AZ-X's full-sized avatar
🏠
restricted IOT anytime, even slow conn to github. All right to the community

AZ-X

🏠
restricted IOT anytime, even slow conn to github. All right to the community
View GitHub Profile
/* eslint-disable prefer-const */
import md5 from 'blueimp-md5'
import bigInt from 'big-integer'
class MyRsa {
constructor () {
// this.n = BigInt('0x8686980c0f5a24c4b9d43020cd2c22703ff3f450756529058b1cf88f09b8602136477198a6e2683149659bd122c33592fdb5ad47944ad1ea4d36c6b172aad6338c3bb6ac6227502d010993ac967d1aef00f0c8e038de2e4d3bc2ec368af2e9f10a6f1eda4f7262f136420c07c331b871bf139f74f3010e3c4fe57df3afb71683')
// this.e = BigInt('0x10001')
this.n = bigInt('8686980c0f5a24c4b9d43020cd2c22703ff3f450756529058b1cf88f09b8602136477198a6e2683149659bd122c33592fdb5ad47944ad1ea4d36c6b172aad6338c3bb6ac6227502d010993ac967d1aef00f0c8e038de2e4d3bc2ec368af2e9f10a6f1eda4f7262f136420c07c331b871bf139f74f3010e3c4fe57df3afb71683', 16)
this.e = bigInt('10001', 16)
@AZ-X
AZ-X / root_windows.go
Last active February 18, 2021 15:34
golang - Secure Windows CryptoAPI calling when verifying certificate
func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) {
...
const CERT_CHAIN_OPT_IN_WEAK_SIGNATURE = 0x00010000 // optional checking SHA1 certificate
err = syscall.CertGetCertificateChain(syscall.Handle(0), storeCtx, verifyTime, storeCtx.Store, para, CCERT_CHAIN_OPT_IN_WEAK_SIGNATURE|CERT_CHAIN_RETURN_LOWER_QUALITY_CONTEXTS, 0, &topCtx)
...
}
@AZ-X
AZ-X / os_windows.go
Last active December 12, 2020 11:06
golang-stdlib RNG migration for Windows
_BCryptGenRandom stdFunction
var bcryptdll = []byte("Bcrypt.dll\000")
bcrypt := windowsLoadSystemLib(bcryptdll)
if bcrypt == 0 {
throw("Bcrypt.dll not found")
}
_BCryptGenRandom = windowsFindfunc(bcrypt, []byte("BCryptGenRandom\000"))