Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
9c7a001a
Commit
9c7a001a
authored
Aug 16, 2016
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New pgp-encode helper function, write_string.
parent
96f1348e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
ChangeLog
ChangeLog
+3
-0
pgp-encode.c
pgp-encode.c
+10
-6
No files found.
ChangeLog
View file @
9c7a001a
2016-08-16 Niels Möller <nisse@lysator.liu.se>
* pgp-encode.c (write_string): New helper function, replacing...
(WRITE): ... deleted macro.
* examples/io.c (write_data): Renamed, and use const void * for
the input data. Updated all callers.
(write_string): ... old name.
...
...
pgp-encode.c
View file @
9c7a001a
...
...
@@ -339,7 +339,11 @@ pgp_crc24(unsigned length, const uint8_t *data)
}
#define WRITE(buffer, s) (nettle_buffer_write(buffer, strlen((s)), (s)))
static
int
write_string
(
struct
nettle_buffer
*
buffer
,
const
char
*
s
)
{
return
nettle_buffer_write
(
buffer
,
strlen
((
s
)),
(
const
uint8_t
*
)
(
s
));
}
/* 15 base 64 groups data per line */
#define BINARY_PER_LINE 45
...
...
@@ -357,9 +361,9 @@ pgp_armor(struct nettle_buffer *buffer,
base64_encode_init
(
&
ctx
);
if
(
!
(
WRITE
(
buffer
,
"BEGIN PGP "
)
&&
WRITE
(
buffer
,
tag
)
&&
WRITE
(
buffer
,
"
\n
Comment: Nettle
\n\n
"
)))
if
(
!
(
write_string
(
buffer
,
"BEGIN PGP "
)
&&
write_string
(
buffer
,
tag
)
&&
write_string
(
buffer
,
"
\n
Comment: Nettle
\n\n
"
)))
return
0
;
for
(;
...
...
@@ -414,7 +418,7 @@ pgp_armor(struct nettle_buffer *buffer,
base64_encode_group
(
p
,
crc
);
}
return
(
WRITE
(
buffer
,
"
\n
BEGIN PGP "
)
&&
WRITE
(
buffer
,
tag
)
return
(
write_string
(
buffer
,
"
\n
BEGIN PGP "
)
&&
write_string
(
buffer
,
tag
)
&&
NETTLE_BUFFER_PUTC
(
buffer
,
'\n'
));
}
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