me when pain

This commit is contained in:
adman
2025-11-30 02:20:40 +01:00
parent d596396553
commit ebf62c8d1c
2 changed files with 231 additions and 2 deletions
+30 -2
View File
@@ -1,8 +1,36 @@
package strom
type SecureChat struct {
import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"github.com/google/uuid"
)
type SecureChatSession struct {
Account *Account
PlayerKeys PlayerKeys
Private *rsa.PrivateKey
SessionId uuid.UUID
}
func FetchSecureChat(account Account) {
func NewSecureChat(a *Account) (s *SecureChatSession, err error) {
s = &SecureChatSession{Account: a}
s.PlayerKeys, err = a.FetchKeys()
if err != nil {
return
}
block, _ := pem.Decode([]byte(s.PlayerKeys.KeyPair.PrivateKey))
k, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
return
}
s.Private = k.(*rsa.PrivateKey)
s.SessionId, err = uuid.NewRandom()
return
}