Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Examples

The following source code can be copied and pasted in a test file, say `test.c`.
This sample shows how dOpenSSL can be used to generate cryptographic keys ---
in this case 2048-bit RSA keys --- in a deterministic way i.e based on a given
in this case 2048-bit RSA keys --- in a deterministic way i.e. based on a given
passphrase. The program therefore assures that, given the same passphrase, the
exact same RSA key will be generated.

Expand All @@ -179,14 +179,14 @@ int main(int argc, char **argv)
char const* passphrase = argv[1];
unsigned int const length = strlen(passphrase);
unsigned int const size = bits / 8;
unsigned int const occurences = size / length + 1;
unsigned int const occurrences = size / length + 1;

unsigned char* seed = malloc(occurences * length + 1);
memset(seed, 0x0, occurences * length + 1);
unsigned char* seed = malloc(occurrences * length + 1);
memset(seed, 0x0, occurrences * length + 1);

/* Concatenate the passphrase so as to create a 256-byte buffer */
unsigned int i;
for (i = 0; i < occurences; i++)
for (i = 0; i < occurrences; i++)
strncpy(seed + (i * length), passphrase, length);

/* Initialize the deterministic random generator */
Expand Down Expand Up @@ -227,7 +227,7 @@ $> gcc -I $HOME/local/include -L $HOME/local/lib -ldopenssl -lcrypto test.c -o t
```

Note that you may need to add the library directory where OpenSSL has been
installed e.g `/usr/lib/`, `/opt/local/lib/` etc.
installed e.g. `/usr/lib/`, `/opt/local/lib/` etc.

```Shell
$> gcc -I $HOME/local/include -L $HOME/local/lib -L /opt/local/lib -ldopenssl -lcrypto test.c -o test
Expand Down
8 changes: 4 additions & 4 deletions src/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ int main(int argc, char **argv)
char const* passphrase = argv[1];
unsigned int const length = strlen(passphrase);
unsigned int const size = bits / 8;
unsigned int const occurences = size / length + 1;
unsigned int const occurrences = size / length + 1;

unsigned char* seed = malloc(occurences * length + 1);
memset(seed, 0x0, occurences * length + 1);
unsigned char* seed = malloc(occurrences * length + 1);
memset(seed, 0x0, occurrences * length + 1);

/* Concatenate the passphrase so as to create a 256-byte buffer */
unsigned int i;
for (i = 0; i < occurences; i++)
for (i = 0; i < occurrences; i++)
strncpy(seed + (i * length), passphrase, length);

/* Initialize the deterministic random generator */
Expand Down
4 changes: 2 additions & 2 deletions tests/dopenssl/bn.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_generate_prime()
{
DOPENSSL_CHECK(dRAND_init() == 1);

// Undeterministically randomly generate numbers should should therefore
// Undeterministically randomly generate numbers should therefore
// all be different, with high probability.
{
BIGNUM* n1 = BN_new();
Expand All @@ -54,7 +54,7 @@ test_generate_prime()
BN_clear_free(n1);
}

// Generate numbers in a deterministic (but probabilist) way, by resetting the
// Generate numbers in a deterministic (but probabilistic) way, by resetting the
// seed for every random generation.
//
// Since based on the same seed, all the generated numbers should be equal.
Expand Down