gcry_create_nonce after a snapshot or checkpoint restore

NIIBE Yutaka gniibe at fsij.org
Thu Oct 29 07:37:22 CET 2026


Hello,

Yuxiang Ji <kurath0307 at icloud.com> wrote:
> If the same-pid case is out of scope, would a sentence in the manual's 
> description of the nonce generator be welcome? For example: "The nonce 
> generator detects a fork by a change of the process ID. A child that 
> keeps its parent's process ID, as after unshare(CLONE_NEWPID) and fork() 
> in a process that is pid 1 of its namespace, and two copies of a process 
> or virtual machine restored from one snapshot continue from the same 
> nonce state." We are glad to send it as a patch.

I think that it should be addressed in the documentation.  I considered
a bit for that, and then, I concluded that some changes (of API and RNG
behavior) are also needed.

For my concern, I created a ticket to track the issue:

    https://static.dev.gnupg.org/T8533.html

My idea here is:

If an RNG implementation and gcry_create_nonce in libgcrypt does not
support VM-fork detection to automatically reseed, it's better for
libgcrypt to offer a method for an application to control the situation.

Suppose that an application wants to use VM-fork notifier to address
this problem, and to reseed.  Currently, with libgcrypt, there is no way
to control gcry_create_nonce, for this case.

If we won't introduce new API, I think that one way is using
gcry_control with GCRYCTL_CLOSE_RANDOM_DEVICE, enhancing the semantics.

Any opinions, comments are welcome.
-- 


More information about the Gcrypt-devel mailing list