Merge transit engine branch, resolve conflicts in shared files
This commit is contained in:
28
internal/engine/helpers.go
Normal file
28
internal/engine/helpers.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/ecdsa"
|
||||
"crypto/ed25519"
|
||||
"crypto/rsa"
|
||||
)
|
||||
|
||||
// ZeroizeKey overwrites an asymmetric private key's sensitive material.
|
||||
func ZeroizeKey(key crypto.PrivateKey) {
|
||||
if key == nil {
|
||||
return
|
||||
}
|
||||
switch k := key.(type) {
|
||||
case *ecdsa.PrivateKey:
|
||||
k.D.SetInt64(0)
|
||||
case *rsa.PrivateKey:
|
||||
k.D.SetInt64(0)
|
||||
for _, p := range k.Primes {
|
||||
p.SetInt64(0)
|
||||
}
|
||||
case ed25519.PrivateKey:
|
||||
for i := range k {
|
||||
k[i] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user