[PD1] crypto changes and TLS almost done
This commit is contained in:
parent
2c4f1fd2fc
commit
5ae7358a0d
13 changed files with 138 additions and 87 deletions
|
@ -5,7 +5,6 @@ import (
|
|||
"PD1/internal/utils/cryptoUtils"
|
||||
"PD1/internal/utils/networking"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Run() {
|
||||
|
@ -16,6 +15,9 @@ func Run() {
|
|||
if flag.NArg() == 0 {
|
||||
panic("No command provided. Use 'help' for instructions.")
|
||||
}
|
||||
//Get user KeyStore
|
||||
password := AskUserPassword()
|
||||
clientKeyStore := cryptoUtils.LoadKeyStore(userFile, password)
|
||||
|
||||
command := flag.Arg(0)
|
||||
switch command {
|
||||
|
@ -24,44 +26,41 @@ func Run() {
|
|||
panic("Insufficient arguments for 'send' command. Usage: send <UID> <SUBJECT>")
|
||||
}
|
||||
uid := flag.Arg(1)
|
||||
subject := flag.Arg(2)
|
||||
messageContent := readMessageContent()
|
||||
//subject := flag.Arg(2)
|
||||
//messageContent := readMessageContent()
|
||||
|
||||
clientCert := cryptoUtils.LoadKeyStore("userdata.p12")
|
||||
cl := networking.NewClient[protocol.Packet](&clientKeyStore)
|
||||
defer cl.Connection.Conn.Close()
|
||||
|
||||
cl := networking.NewClient[protocol.Packet](clientCert)
|
||||
defer cl.Connection.Conn.Close()
|
||||
certRequestPacket := protocol.NewRequestUserCertPacket(uid)
|
||||
cl.Connection.Send(certRequestPacket)
|
||||
//certPacket := cl.Connection.Receive()
|
||||
|
||||
|
||||
certRequestPacket := protocol.NewRequestUserCertPacket(uid)
|
||||
cl.Connection.Send(certRequestPacket)
|
||||
certPacket := cl.Connection.Receive()
|
||||
|
||||
// TODO: Encrypt message
|
||||
submitMessage(cl,uid,cipherContent)
|
||||
// TODO: Encrypt message
|
||||
//submitMessage(cl, uid, cipherContent)
|
||||
|
||||
case "askqueue":
|
||||
cl := networking.NewClient[protocol.Packet]()
|
||||
defer cl.Connection.Conn.Close()
|
||||
cl := networking.NewClient[protocol.Packet](&clientKeyStore)
|
||||
defer cl.Connection.Conn.Close()
|
||||
|
||||
case "getmsg":
|
||||
if flag.NArg() < 2 {
|
||||
panic("Insufficient arguments for 'getmsg' command. Usage: getmsg <NUM>")
|
||||
}
|
||||
num := flag.Arg(1)
|
||||
cl := networking.NewClient[protocol.Packet]()
|
||||
defer cl.Connection.Conn.Close()
|
||||
//num := flag.Arg(1)
|
||||
cl := networking.NewClient[protocol.Packet](&clientKeyStore)
|
||||
defer cl.Connection.Conn.Close()
|
||||
|
||||
case "help":
|
||||
showHelp()
|
||||
showHelp()
|
||||
|
||||
default:
|
||||
commandError()
|
||||
commandError()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func submitMessage(cl networking.Client[protocol.Packet],uid string, content []byte) {
|
||||
pack := protocol.NewSubmitMessage(uid,content)
|
||||
func submitMessage(cl networking.Client[protocol.Packet], uid string, content []byte) {
|
||||
pack := protocol.NewSubmitMessagePacket(uid, content)
|
||||
cl.Connection.Send(pack)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue