Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ad01fbde
authored
Jul 23, 2019
by
Enrico Pozzobon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified linux template to allow nocrypt
parent
6a6c6617
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
templates/linux/main.c
+23
-22
No files found.
templates/linux/main.c
View file @
ad01fbde
...
...
@@ -34,7 +34,7 @@ unsigned long long nplen = NPUB_LENGTH;
unsigned
char
*
k
=
NULL
;
unsigned
long
long
klen
=
KEY_LENGTH
;
static
void
re
ad
_variable
(
unsigned
char
**
target
,
unsigned
long
long
*
lenp
)
{
static
void
re
cv
_variable
(
unsigned
char
**
target
,
unsigned
long
long
*
lenp
)
{
if
(
*
target
!=
NULL
)
{
free
(
*
target
);
}
...
...
@@ -46,26 +46,25 @@ static void read_variable(unsigned char **target, unsigned long long *lenp) {
}
*
lenp
=
len
;
if
(
*
lenp
==
0
)
{
*
target
=
NULL
;
return
;
}
*
target
=
malloc
(
*
lenp
);
*
target
=
malloc
(
len
);
if
(
NULL
==
*
target
)
{
fprintf
(
stderr
,
"ERROR: couldn't malloc %
llu bytes
\r\n
"
,
*
lenp
);
fprintf
(
stderr
,
"ERROR: couldn't malloc %
u bytes
\r\n
"
,
len
);
exit
(
2
);
}
if
(
*
lenp
==
0
)
{
return
;
}
if
(
1
!=
fread
(
*
target
,
*
lenp
,
1
,
stdin
))
{
fprintf
(
stderr
,
"ERROR: didn't read %
llu bytes of data
\r\n
"
,
*
lenp
);
fprintf
(
stderr
,
"ERROR: didn't read %
u bytes of data
\r\n
"
,
len
);
exit
(
1
);
}
}
static
void
write
_variable
(
unsigned
char
*
target
,
unsigned
long
long
len
)
{
static
void
send
_variable
(
unsigned
char
*
target
,
unsigned
long
long
len
)
{
uint32_t
olen
=
len
;
if
(
1
!=
fwrite
(
&
olen
,
sizeof
(
olen
),
1
,
stdout
))
{
fprintf
(
stderr
,
"ERROR: didn't write length
\r\n
"
);
...
...
@@ -92,22 +91,23 @@ int main() {
while
(
1
)
{
if
(
1
!=
fread
(
&
action
,
sizeof
(
action
),
1
,
stdin
))
return
1
;
fprintf
(
stderr
,
"DEBUG: received action 0x%02x
\r\n
"
,
action
);
switch
(
action
)
{
case
'c'
:
re
ad
_variable
(
&
c
,
&
clen
);
break
;
case
'm'
:
re
ad
_variable
(
&
m
,
&
mlen
);
break
;
case
'a'
:
re
ad
_variable
(
&
ad
,
&
adlen
);
break
;
case
'k'
:
re
ad
_variable
(
&
k
,
&
klen
);
break
;
case
'c'
:
re
cv
_variable
(
&
c
,
&
clen
);
break
;
case
'm'
:
re
cv
_variable
(
&
m
,
&
mlen
);
break
;
case
'a'
:
re
cv
_variable
(
&
ad
,
&
adlen
);
break
;
case
'k'
:
re
cv
_variable
(
&
k
,
&
klen
);
break
;
case
's'
:
re
ad
_variable
(
&
nsec
,
&
nslen
);
break
;
case
'p'
:
re
ad
_variable
(
&
npub
,
&
nplen
);
break
;
case
's'
:
re
cv
_variable
(
&
nsec
,
&
nslen
);
break
;
case
'p'
:
re
cv
_variable
(
&
npub
,
&
nplen
);
break
;
case
'C'
:
write
_variable
(
c
,
clen
);
break
;
case
'M'
:
write
_variable
(
m
,
mlen
);
break
;
case
'A'
:
write
_variable
(
ad
,
adlen
);
break
;
case
'K'
:
write
_variable
(
k
,
klen
);
break
;
case
'S'
:
write
_variable
(
nsec
,
nslen
);
break
;
case
'P'
:
write
_variable
(
npub
,
nplen
);
break
;
case
'C'
:
send
_variable
(
c
,
clen
);
break
;
case
'M'
:
send
_variable
(
m
,
mlen
);
break
;
case
'A'
:
send
_variable
(
ad
,
adlen
);
break
;
case
'K'
:
send
_variable
(
k
,
klen
);
break
;
case
'S'
:
send
_variable
(
nsec
,
nslen
);
break
;
case
'P'
:
send
_variable
(
npub
,
nplen
);
break
;
case
'e'
:
...
...
@@ -124,6 +124,7 @@ int main() {
fprintf(stderr, "klen = %llu\r\n", klen);
fprintf(stderr, "k = "); FPRINTF_HEX(stderr, k, klen); fprintf(stderr, "\r\n");
*/
if
(
k
==
NULL
)
{
fprintf
(
stderr
,
"Missing key
\r\n
"
);
return
3
;
...
...
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