mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-02-03 13:53:42 +00:00
don't expose private api
This commit is contained in:
parent
0fb1f1c5b8
commit
58cdefac21
@ -62,7 +62,7 @@ type
|
|||||||
of SecureMacType.Sha1:
|
of SecureMacType.Sha1:
|
||||||
ctxsha1: HMAC[sha1]
|
ctxsha1: HMAC[sha1]
|
||||||
|
|
||||||
SecureConnection* = ref object of Connection
|
SecureConnection = ref object of Connection
|
||||||
writerMac: SecureMac
|
writerMac: SecureMac
|
||||||
readerMac: SecureMac
|
readerMac: SecureMac
|
||||||
writerCoder: SecureCipher
|
writerCoder: SecureCipher
|
||||||
@ -176,7 +176,7 @@ proc macCheckAndDecode(sconn: SecureConnection, data: var seq[byte]): bool =
|
|||||||
data.setLen(mark)
|
data.setLen(mark)
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc readMessage*(sconn: SecureConnection): Future[seq[byte]] {.async.} =
|
proc readMessage(sconn: SecureConnection): Future[seq[byte]] {.async.} =
|
||||||
## Read message from channel secure connection ``sconn``.
|
## Read message from channel secure connection ``sconn``.
|
||||||
try:
|
try:
|
||||||
var buf = newSeq[byte](4)
|
var buf = newSeq[byte](4)
|
||||||
@ -201,7 +201,7 @@ proc readMessage*(sconn: SecureConnection): Future[seq[byte]] {.async.} =
|
|||||||
except AsyncStreamReadError:
|
except AsyncStreamReadError:
|
||||||
trace "Error reading from connection"
|
trace "Error reading from connection"
|
||||||
|
|
||||||
proc writeMessage*(sconn: SecureConnection, message: seq[byte]) {.async.} =
|
proc writeMessage(sconn: SecureConnection, message: seq[byte]) {.async.} =
|
||||||
## Write message ``message`` to secure connection ``sconn``.
|
## Write message ``message`` to secure connection ``sconn``.
|
||||||
let macsize = sconn.writerMac.sizeDigest()
|
let macsize = sconn.writerMac.sizeDigest()
|
||||||
var msg = newSeq[byte](len(message) + 4 + macsize)
|
var msg = newSeq[byte](len(message) + 4 + macsize)
|
||||||
@ -221,12 +221,12 @@ proc writeMessage*(sconn: SecureConnection, message: seq[byte]) {.async.} =
|
|||||||
except AsyncStreamWriteError:
|
except AsyncStreamWriteError:
|
||||||
trace "Could not write to connection"
|
trace "Could not write to connection"
|
||||||
|
|
||||||
proc newSecureConnection*(conn: Connection,
|
proc newSecureConnection(conn: Connection,
|
||||||
hash: string,
|
hash: string,
|
||||||
cipher: string,
|
cipher: string,
|
||||||
secrets: Secret,
|
secrets: Secret,
|
||||||
order: int,
|
order: int,
|
||||||
remotePubKey: PublicKey): SecureConnection =
|
remotePubKey: PublicKey): SecureConnection =
|
||||||
## Create new secure connection, using specified hash algorithm ``hash``,
|
## Create new secure connection, using specified hash algorithm ``hash``,
|
||||||
## cipher algorithm ``cipher``, stretched keys ``secrets`` and order
|
## cipher algorithm ``cipher``, stretched keys ``secrets`` and order
|
||||||
## ``order``.
|
## ``order``.
|
||||||
@ -280,7 +280,7 @@ proc transactMessage(conn: Connection,
|
|||||||
except AsyncStreamWriteError:
|
except AsyncStreamWriteError:
|
||||||
trace "Could not write to connection", conn = conn
|
trace "Could not write to connection", conn = conn
|
||||||
|
|
||||||
proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.} =
|
proc handshake(s: Secio, conn: Connection): Future[SecureConnection] {.async.} =
|
||||||
var
|
var
|
||||||
localNonce: array[SecioNonceSize, byte]
|
localNonce: array[SecioNonceSize, byte]
|
||||||
remoteNonce: seq[byte]
|
remoteNonce: seq[byte]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user