Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
97eec99c
Commit
97eec99c
authored
7 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Add support for ECDSA keys.
Also, free() temp variables for RSA keys.
parent
80509db5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/js_cryptcon.c
+96
-2
96 additions, 2 deletions
src/sbbs3/js_cryptcon.c
src/sbbs3/prntfile.cpp
+1
-3
1 addition, 3 deletions
src/sbbs3/prntfile.cpp
with
97 additions
and
5 deletions
src/sbbs3/js_cryptcon.c
+
96
−
2
View file @
97eec99c
...
...
@@ -85,6 +85,79 @@ static unsigned char js_asn1_type(unsigned char *data, size_t len, size_t *off)
return
t
;
}
static
int
js_ecc_to_prop
(
unsigned
char
*
data
,
size_t
len
,
size_t
*
off
,
JSContext
*
cx
,
JSObject
*
parent
)
{
size_t
sz
;
JSObject
*
obj
;
JSString
*
xstr
;
JSString
*
ystr
;
char
*
x
;
char
*
y
;
char
*
x64
;
char
*
y64
;
size_t
half
;
if
(
js_asn1_type
(
data
,
len
,
off
)
==
3
)
{
sz
=
js_asn1_len
(
data
,
len
,
off
);
if
(
data
[
*
off
]
==
0
&&
data
[(
*
off
)
+
1
]
==
4
&&
((
sz
%
1
)
==
0
))
{
half
=
(
sz
-
2
)
/
2
;
x
=
malloc
(
half
);
if
(
x
==
NULL
)
return
0
;
memcpy
(
x
,
data
+
(
*
off
)
+
2
,
half
);
x64
=
malloc
(
half
*
4
/
3
+
3
);
if
(
x64
==
NULL
)
{
free
(
x
);
return
0
;
}
b64_encode
(
x64
,
half
*
4
/
3
+
3
,
x
,
half
);
free
(
x
);
for
(
x
=
x64
;
*
x
;
x
++
)
{
if
(
*
x
==
'+'
)
*
x
=
'-'
;
else
if
(
*
x
==
'/'
)
*
x
=
'_'
;
else
if
(
*
x
==
'='
)
*
x
=
0
;
}
y
=
malloc
(
half
);
if
(
y
==
NULL
)
return
0
;
memcpy
(
y
,
data
+
(
*
off
)
+
2
+
half
,
half
);
y64
=
malloc
(
half
*
4
/
3
+
3
);
if
(
y64
==
NULL
)
{
free
(
y
);
return
0
;
}
b64_encode
(
y64
,
half
*
4
/
3
+
3
,
x
,
half
);
free
(
y
);
for
(
y
=
y64
;
*
y
;
y
++
)
{
if
(
*
y
==
'+'
)
*
y
=
'-'
;
else
if
(
*
y
==
'/'
)
*
y
=
'_'
;
else
if
(
*
y
==
'='
)
*
y
=
0
;
}
obj
=
JS_NewObject
(
cx
,
NULL
,
NULL
,
parent
);
JS_DefineProperty
(
cx
,
parent
,
"public_key"
,
OBJECT_TO_JSVAL
(
obj
),
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
xstr
=
JS_NewStringCopyZ
(
cx
,
x64
);
free
(
x64
);
if
(
xstr
!=
NULL
)
JS_DefineProperty
(
cx
,
obj
,
"x"
,
STRING_TO_JSVAL
(
xstr
),
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
ystr
=
JS_NewStringCopyZ
(
cx
,
y64
);
free
(
y64
);
if
(
ystr
!=
NULL
)
JS_DefineProperty
(
cx
,
obj
,
"y"
,
STRING_TO_JSVAL
(
ystr
),
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
JS_DeepFreezeObject
(
cx
,
obj
);
return
1
;
}
}
return
0
;
}
static
void
js_simple_asn1
(
unsigned
char
*
data
,
size_t
len
,
JSContext
*
cx
,
JSObject
*
parent
)
{
unsigned
char
t
;
...
...
@@ -189,16 +262,37 @@ static void js_simple_asn1(unsigned char *data, size_t len, JSContext *cx, JSObj
obj
=
JS_NewObject
(
cx
,
NULL
,
NULL
,
parent
);
JS_DefineProperty
(
cx
,
parent
,
"public_key"
,
OBJECT_TO_JSVAL
(
obj
),
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
nstr
=
JS_NewStringCopyZ
(
cx
,
n64
);
free
(
n64
);
if
(
nstr
!=
NULL
)
JS_DefineProperty
(
cx
,
obj
,
"n"
,
STRING_TO_JSVAL
(
nstr
),
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
estr
=
JS_NewStringCopyZ
(
cx
,
e64
);
free
(
e64
);
if
(
estr
!=
NULL
)
JS_DefineProperty
(
cx
,
obj
,
"e"
,
STRING_TO_JSVAL
(
estr
),
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
JS_DeepFreezeObject
(
cx
,
obj
);
}
off
=
len
;
}
off
+=
sz
;
else
if
(
strncmp
((
char
*
)
data
+
off
,
"
\x2A\x86\x48\xCE\x3D\x03\x01\x07
"
,
8
)
==
0
)
{
// P-256
off
+=
sz
;
if
(
js_ecc_to_prop
(
data
,
len
,
&
off
,
cx
,
parent
))
off
=
len
;
}
else
if
(
strncmp
((
char
*
)
data
+
off
,
"
\x2B\x81\x04\x00\x22
"
,
5
)
==
0
)
{
// P-384
off
+=
sz
;
if
(
js_ecc_to_prop
(
data
,
len
,
&
off
,
cx
,
parent
))
off
=
len
;
}
else
if
(
strncmp
((
char
*
)
data
+
off
,
"
\x2B\x81\x04\x00\x23
"
,
5
)
==
0
)
{
// P-521
off
+=
sz
;
if
(
js_ecc_to_prop
(
data
,
len
,
&
off
,
cx
,
parent
))
off
=
len
;
}
if
(
off
<
len
)
off
+=
sz
;
break
;
default:
off
+=
sz
;
...
...
@@ -227,7 +321,7 @@ static void js_create_key_object(JSContext *cx, JSObject *parent)
lprintf
(
LOG_ERR
,
"cryptGetAttribute(ALGO) returned %d
\n
"
,
status
);
goto
resume
;
}
if
(
val
!=
CRYPT_ALGO_RSA
)
if
(
val
!=
CRYPT_ALGO_RSA
&&
val
!=
CRYPT_ALGO_ECDSA
)
goto
resume
;
status
=
cryptCreateCert
(
&
cert
,
CRYPT_UNUSED
,
CRYPT_CERTTYPE_CERTIFICATE
);
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/prntfile.cpp
+
1
−
3
View file @
97eec99c
...
...
@@ -228,6 +228,4 @@ bool sbbs_t::menu_exists(const char *code)
return
fexistcase
(
menu_file
)
?
true
:
false
;
backslash
(
menu_dir
);
SAFEPRINTF3
(
path
,
"%smenu/%s%s.asc"
,
cfg
.
text_dir
,
menu_dir
,
code
);
return
fexistcase
(
path
)
?
true
:
false
;
}
SAFEPRINTF3
(
path
,
"%smenu/%s%s.asc"
,
cfg
.
text_dir
,
menu_di
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment