whip initial secio

This commit is contained in:
Dmitriy Ryajov 2019-09-09 11:33:51 -06:00
parent 435c69633f
commit d27ea5d228
3 changed files with 79 additions and 3 deletions

View File

@ -0,0 +1,32 @@
## Nim-LibP2P
## Copyright (c) 2018 Status Research & Development GmbH
## Licensed under either of
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
## at your option.
## This file may not be copied, modified, or distributed except according to
## those terms.
import chronos
import secure,
../../connection
const SecioCodec* = "/plaintext/1.0.0"
type
Secio = ref object of Secure
proc encodeProposalMsg*() = discard
proc decodeProposalMsg*() = discard
method init(p: Secio) {.gcsafe.} =
proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
discard
p.codec = SecioCodec
p.handler = handle
proc newSecio*(): Secio =
new result
result.init()

View File

@ -0,0 +1,40 @@
## Nim-LibP2P
## Copyright (c) 2018 Status Research & Development GmbH
## Licensed under either of
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
## at your option.
## This file may not be copied, modified, or distributed except according to
## those terms.
type
Exchanges* {.pure.} = enum
P256 = "P-256",
P384 = "P-384",
P521 = "P-521"
Ciphers* {.pure.} = enum
AES256 = "AES-256",
AES128 = "AES-128"
Hashes* {.pure.} = enum
SHA256 = "SHA256"
SHA512 = "SHA512"
Propose* = tuple
rand: seq[byte]
pubkey: seq[byte]
exchanges: string
ciphers: string
hashes: string
Exchange = tuple
epubkey: seq[byte]
signature: seq[byte]
proc proposal*() = discard
proc exchange*() = discard
proc selectBest*() = discard
proc verify*() = discard
proc generateKeys*() = discard
proc verifyNonce*() = discard

View File

@ -8,8 +8,8 @@
## those terms. ## those terms.
import chronos import chronos
import protocol import ../protocol
import ../connection import ../../connection
const PlainTextCodec* = "/plaintext/1.0.0" const PlainTextCodec* = "/plaintext/1.0.0"
@ -19,12 +19,16 @@ type
PlainText* = ref object of Secure PlainText* = ref object of Secure
method init(p: PlainText) {.gcsafe.} = method init(p: PlainText) {.gcsafe.} =
proc handle(conn: Connection, proto: string) {.async, gcsafe.} = discard proc handle(conn: Connection, proto: string)
{.async, gcsafe.} = discard
## plain text doesn't do anything ## plain text doesn't do anything
p.codec = PlainTextCodec p.codec = PlainTextCodec
p.handler = handle p.handler = handle
method secure(p: Secure, conn: Connection): Future[Connection]
{.base, async, gcsafe.} = discard
proc newPlainText*(): PlainText = proc newPlainText*(): PlainText =
new result new result
result.init() result.init()