github.com/epfl-dcsl/gotee@v0.0.0-20200909122901-014b35f5e5e9/src/teecert/impl.go (about) 1 package teecert 2 3 import ( 4 "crypto/rsa" 5 "teecomm" 6 ) 7 8 func check(err error) { 9 if err != nil { 10 panic(err.Error()) 11 } 12 } 13 14 func TeeProtectKey(req chan *rsa.PrivateKey) { 15 orig := <-req 16 copy := &rsa.PrivateKey{} 17 *copy = *orig 18 req <- copy 19 } 20 21 func TeeDecryptService(comm chan teecomm.DecrRequestMsg) { 22 for { 23 req := <-comm 24 err := rsa.DecryptPKCS1v15SessionKey(nil, req.Key, req.Msg, req.Plaintxt) 25 check(err) 26 req.Done <- true 27 } 28 }