#1 2024-11-08 23:23:59

Uefi
Member
Registered: 2024-02-14
Posts: 38

TAESPRNG manual seed

Hi how can I assign to manually seed for TAESPRNG Random Generator ?

function GenRandom: integer;
var
prng:TAESPRNG;
begin
prng:=TAESPRNG.Create;
prng.Seed:=57454654; // ????????????
Result:= prng.Random64;
prng.Free;
end;

Last edited by Uefi (2024-11-08 23:29:04)

Offline

#2 2024-11-09 02:45:08

zen010101
Member
Registered: 2024-06-15
Posts: 66

Re: TAESPRNG manual seed

Seed is a procedure instead of a property. See it comments:

/// would force the internal generator to re-seed its private key
    // - avoid potential attacks on backward or forward security
    // - would be called by FillRandom() methods, according to SeedAfterBytes
    // - this method is thread-safe

So, no need to set the SEED manually, just using those properties:

/// after how many generated bytes Seed method would be called
    // - default is 32 MB - i.e. 21-bit CTR rounds which seems paranoid enough
    // - if set to 0 - e.g. for TSystemPrng - no seeding will occur
    property SeedAfterBytes: PtrUInt
      read fSeedAfterBytes;
    /// how many Pbkdf2HmacSha512 count is applied by Seed to the entropy
    // - default is 16 rounds, which is more than enough for entropy gathering,
    // since GetEntropy output comes from a SHAKE-256 generator in XOF mode
    property SeedPbkdf2Round: cardinal
      read fSeedPbkdf2Round;
    /// the source of entropy used during seeding - faster gesUserOnly by default
    property SeedEntropySource: TAesPrngGetEntropySource
      read fSeedEntropySource;

Offline

#3 2024-11-09 07:39:53

Uefi
Member
Registered: 2024-02-14
Posts: 38

Re: TAESPRNG manual seed

Are you a fool? These properties are not assigned; they are read-only!

Offline

#4 2024-11-09 08:36:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: TAESPRNG manual seed

There is no point.

Use directly an AES-CTR generator with a fixed key and IV.

Or use mormot.core.base Lecuyer generator, which allows a 32-bit seed and is good enough as generator.

Offline

#5 2024-11-09 09:14:02

Uefi
Member
Registered: 2024-02-14
Posts: 38

Re: TAESPRNG manual seed

ab wrote:

There is no point.

Use directly an AES-CTR generator with a fixed key and IV.

Or use mormot.core.base Lecuyer generator, which allows a 32-bit seed and is good enough as generator.

Hello, I tested Lecuyer, it doesn’t have the FillRandomHex I need like in TAESPRNG sad

Offline

#6 2024-11-09 17:44:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: TAESPRNG manual seed

Use Lecuyer + mormot.core.text for hexa.

Offline

#7 2024-11-09 21:01:20

Uefi
Member
Registered: 2024-02-14
Posts: 38

Re: TAESPRNG manual seed

ab wrote:

Use Lecuyer + mormot.core.text for hexa.

If you can, please provide an example of the code, otherwise it’s not clear at all smile

Offline

Board footer

Powered by FluxBB