File tree Expand file tree Collapse file tree 4 files changed +6
-12
lines changed
Expand file tree Collapse file tree 4 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ suite "Decode frame extensions flow":
121121 var
122122 address: TransportAddress
123123 server: StreamServer
124- maskKey = genMaskKey (newRng ())
124+ maskKey = genMaskKey (HmacDrbgContext . new ())
125125 transport: StreamTransport
126126 reader: AsyncStreamReader
127127 frame: Frame
Original file line number Diff line number Diff line change @@ -806,7 +806,7 @@ suite "Test Payload":
806806 address = initTAddress (" 127.0.0.1:8888" ),
807807 frameSize = maxFrameSize)
808808
809- let maskKey = genMaskKey (newRng ())
809+ let maskKey = genMaskKey (HmacDrbgContext . new ())
810810 await session.stream.writer.write (
811811 (await Frame (
812812 fin: false ,
@@ -866,7 +866,7 @@ suite "Test Payload":
866866 pong = true
867867 )
868868
869- let maskKey = genMaskKey (newRng ())
869+ let maskKey = genMaskKey (HmacDrbgContext . new ())
870870 await session.stream.writer.write (
871871 (await Frame (
872872 fin: false ,
Original file line number Diff line number Diff line change @@ -13,13 +13,7 @@ export rand
1313# # Random helpers: similar as in stdlib, but with HmacDrbgContext rng
1414const randMax = 18_446_744_073_709_551_615 'u64
1515
16- type
17- Rng * = ref HmacDrbgContext
18-
19- proc newRng * (): Rng =
20- # You should only create one instance of the RNG per application / library
21- # Ref is used so that it can be shared between components
22- HmacDrbgContext .new ()
16+ type Rng * = ref HmacDrbgContext
2317
2418proc rand * (rng: Rng , max: Natural ): int =
2519 if max == 0 : return 0
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ proc connect*(
120120 rng: Rng = nil ): Future [WSSession ] {.async .} =
121121
122122 let
123- rng = if isNil (rng): newRng () else : rng
123+ rng = if isNil (rng): HmacDrbgContext . new () else : rng
124124 key = Base64Pad .encode (genWebSecKey (rng))
125125 hostname = if hostName.len > 0 : hostName else : $ host
126126
@@ -364,7 +364,7 @@ proc new*(
364364 return WSServer (
365365 protocols: @ protos,
366366 masked: false ,
367- rng: if isNil (rng): newRng () else : rng,
367+ rng: if isNil (rng): HmacDrbgContext . new () else : rng,
368368 frameSize: frameSize,
369369 factories: @ factories,
370370 onPing: onPing,
You can’t perform that action at this time.
0 commit comments