Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dmitry Baryshkov
nettle
Commits
9c7a001a
Commit
9c7a001a
authored
Aug 16, 2016
by
Niels Möller
Browse files
New pgp-encode helper function, write_string.
parent
96f1348e
Changes
2
Hide whitespace changes
Inline
Side-by-side
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
Supports
Markdown
0%
Try again
or
attach a new 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