Skip to content

Commit

Permalink
introducing TAESPRNG class
Browse files Browse the repository at this point in the history
as a cryptographic pseudorandom number generators (CSPRNG)
based on AES-256 and OS returned entropy
  • Loading branch information
Arnaud Bouchez committed Apr 8, 2016
1 parent 60566e8 commit 92135fc
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 48 deletions.
2 changes: 1 addition & 1 deletion SynBidirSock.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ function THttpClientWebSockets.WebSocketsUpgrade(const aWebSocketsURI,
aWebSocketsURI,aWebSocketsEncryptionKey,aWebSocketsCompression);
try
RequestSendHeader(aWebSocketsURI,'GET');
FillRandom(key);
TAESPRNG.Main.FillRandom(key);
bin1 := BinToBase64(@key,sizeof(key));
SockSend(['Content-Length: 0'#13#10'Connection: Upgrade'#13#10+
'Upgrade: websocket'#13#10'Sec-WebSocket-Key: ',bin1,#13#10+
Expand Down
2 changes: 2 additions & 0 deletions SynCommons.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5700,6 +5700,8 @@ function GUIDToString(const guid: TGUID): string;

/// fill some memory buffer with random values
// - the destination buffer is expected to be allocated as 32 bit items
// - consider using instead the much safer TAESPRNG.Main.FillRandom() method
// from the SynCrypto unit
procedure FillRandom(Dest: PCardinalArray; CardinalCount: integer);

/// compute a random GUID value
Expand Down
Loading

0 comments on commit 92135fc

Please sign in to comment.