Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
42397bc9
Commit
42397bc9
authored
Feb 14, 2013
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added -s and -e options to examples/rsa-keygen.
parent
39c03743
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
ChangeLog
ChangeLog
+6
-0
examples/rsa-keygen.c
examples/rsa-keygen.c
+34
-4
No files found.
ChangeLog
View file @
42397bc9
2013-02-14 Niels Möller <nisse@lysator.liu.se>
* examples/rsa-keygen.c (uint_arg): New function.
(main): New options -s and -e, to specify key size and public
exponent. Increased default key size to 2048.
2013-02-12 Niels Möller <nisse@lysator.liu.se>
* armv7/memxor.asm (memxor): Optimized aligned case, using 3-way
...
...
examples/rsa-keygen.c
View file @
42397bc9
...
...
@@ -41,7 +41,7 @@
#include "getopt.h"
#define
KEYSIZE 900
#define
DEFAULT_KEYSIZE 2048
#define ESIZE 30
static
void
...
...
@@ -51,6 +51,22 @@ progress(void *ctx, int c)
fputc
(
c
,
stderr
);
}
static
unsigned
long
uint_arg
(
char
c
,
const
char
*
arg
)
{
unsigned
long
val
;
char
*
end
;
val
=
strtoul
(
arg
,
&
end
,
0
);
if
(
*
arg
==
'\0'
||
*
end
!=
'\0'
)
{
werror
(
"Invalid integer argument for -%c option.
\n
"
,
c
);
exit
(
EXIT_FAILURE
);
}
return
val
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -66,6 +82,9 @@ main(int argc, char **argv)
struct
nettle_buffer
pub_buffer
;
struct
nettle_buffer
priv_buffer
;
unsigned
long
key_size
=
DEFAULT_KEYSIZE
;
unsigned
long
key_e
=
0
;
enum
{
OPT_HELP
=
300
};
static
const
struct
option
options
[]
=
{
...
...
@@ -75,9 +94,9 @@ main(int argc, char **argv)
{
NULL
,
0
,
NULL
,
0
}
};
while
(
(
c
=
getopt_long
(
argc
,
argv
,
"o:r:"
,
options
,
NULL
))
!=
-
1
)
while
(
(
c
=
getopt_long
(
argc
,
argv
,
"o:r:
e:s:
"
,
options
,
NULL
))
!=
-
1
)
switch
(
c
)
{
{
case
'o'
:
priv_name
=
optarg
;
break
;
...
...
@@ -86,6 +105,14 @@ main(int argc, char **argv)
random_name
=
optarg
;
break
;
case
's'
:
key_size
=
uint_arg
(
's'
,
optarg
);
break
;
case
'e'
:
key_e
=
uint_arg
(
'e'
,
optarg
);
break
;
case
OPT_HELP
:
printf
(
"FIXME: Usage information.
\n
"
);
return
EXIT_SUCCESS
;
...
...
@@ -119,11 +146,14 @@ main(int argc, char **argv)
rsa_public_key_init
(
&
pub
);
rsa_private_key_init
(
&
priv
);
if
(
key_e
)
mpz_set_ui
(
pub
.
e
,
key_e
);
if
(
!
rsa_generate_keypair
(
&
pub
,
&
priv
,
(
void
*
)
&
yarrow
,
(
nettle_random_func
*
)
yarrow256_random
,
NULL
,
progress
,
KEYSIZE
,
ESIZE
))
key_size
,
key_e
==
0
?
ESIZE
:
0
))
{
werror
(
"Key generation failed.
\n
"
);
return
EXIT_FAILURE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment