Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
8a1712b3
Commit
8a1712b3
authored
22 years ago
by
tewk
Browse files
Options
Downloads
Patches
Plain Diff
Credential Utilities checkin
parent
62b8c5a4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/credential_utils.c
+125
-0
125 additions, 0 deletions
src/common/credential_utils.c
src/common/credential_utils.h
+28
-0
28 additions, 0 deletions
src/common/credential_utils.h
src/slurmd/Makefile.am
+2
-2
2 additions, 2 deletions
src/slurmd/Makefile.am
with
155 additions
and
2 deletions
src/common/credential_utils.c
0 → 100644
+
125
−
0
View file @
8a1712b3
#include
<stdio.h>
#include
<openssl/rsa.h>
#include
<openssl/evp.h>
#include
<openssl/objects.h>
#include
<openssl/x509.h>
#include
<openssl/err.h>
#include
<openssl/pem.h>
#include
<openssl/ssl.h>
#include
<src/common/log.h>
#include
<src/common/xmalloc.h>
#include
<src/common/slurm_errno.h>
#include
<src/common/slurm_protocol_errno.h>
#include
<src/common/slurm_protocol_api.h>
#include
<src/slurmd/credential_utils.h>
int
ssl_init
(
)
{
ERR_load_crypto_strings
();
return
SLURM_SUCCESS
;
}
int
ssl_destroy
(
)
{
ERR_free_strings
();
return
SLURM_SUCCESS
;
}
int
init_signer
(
credential_tools_ctx_t
*
ctx
,
char
*
path
)
{
int
local_errno
;
FILE
*
key_file
;
if
(
(
key_file
=
fopen
(
path
,
"r"
)
)
==
NULL
)
{
local_errno
=
errno
;
error
(
"error opening credential sign key file , errno %i"
,
local_errno
)
;
};
ctx
->
key
.
private
=
PEM_read_PrivateKey
(
key_file
,
NULL
,
NULL
,
NULL
)
;
fclose
(
key_file
)
;
if
(
ctx
->
key
.
private
==
NULL
)
{
ERR_print_errors_fp
(
stderr
);
slurm_seterrno
(
ESLURMD_OPENSSL_ERROR
)
;
return
SLURM_ERROR
;
}
return
SLURM_SUCCESS
;
}
int
init_verifier
(
credential_tools_ctx_t
*
ctx
,
char
*
path
)
{
int
local_errno
;
X509
*
x509
;
FILE
*
cert_file
;
if
(
(
cert_file
=
fopen
(
path
,
"r"
)
)
==
NULL
)
{
local_errno
=
errno
;
error
(
"error opening certificate file , errno %i"
,
local_errno
)
;
};
x509
=
PEM_read_X509
(
cert_file
,
NULL
,
NULL
,
NULL
)
;
fclose
(
cert_file
)
;
if
(
x509
==
NULL
)
{
ERR_print_errors_fp
(
stderr
);
slurm_seterrno
(
ESLURMD_OPENSSL_ERROR
)
;
return
SLURM_ERROR
;
}
ctx
->
key
.
public
=
X509_get_pubkey
(
x509
)
;
X509_free
(
x509
)
;
if
(
ctx
->
key
.
public
==
NULL
)
{
ERR_print_errors_fp
(
stderr
);
slurm_seterrno
(
ESLURMD_OPENSSL_ERROR
)
;
return
SLURM_ERROR
;
}
return
SLURM_SUCCESS
;
}
int
destroy_credential_ctx
(
credential_tools_ctx_t
*
ctx
)
{
if
(
ctx
)
{
EVP_PKEY_free
(
ctx
->
key
.
private
)
;
xfree
(
ctx
)
;
}
return
SLURM_SUCCESS
;
}
int
credential_sign
(
credential_tools_ctx_t
*
ctx
,
char
*
data_buffer
,
int
data_length
,
char
*
signature_buffer
,
int
*
signature_length
)
{
int
rc
;
EVP_MD_CTX
md_ctx
;
EVP_SignInit
(
&
md_ctx
,
EVP_dss1
(
)
)
;
EVP_SignUpdate
(
&
md_ctx
,
data_buffer
,
data_length
)
;
if
(
(
rc
=
EVP_SignFinal
(
&
md_ctx
,
signature_buffer
,
signature_length
,
ctx
->
key
.
private
)
)
!=
SLURM_OPENSSL_SIGNED
)
{
ERR_print_errors_fp
(
stderr
);
slurm_seterrno
(
ESLURMD_OPENSSL_ERROR
)
;
return
SLURM_ERROR
;
}
return
SLURM_SUCCESS
;
}
int
credential_verify
(
credential_tools_ctx_t
*
ctx
,
char
*
data_buffer
,
int
data_length
,
char
*
signature_buffer
,
int
signature_length
)
{
int
rc
;
EVP_MD_CTX
md_ctx
;
EVP_VerifyInit
(
&
md_ctx
,
EVP_dss1
(
)
)
;
EVP_VerifyUpdate
(
&
md_ctx
,
data_buffer
,
data_length
)
;
if
(
(
rc
=
EVP_VerifyFinal
(
&
md_ctx
,
signature_buffer
,
signature_length
,
ctx
->
key
.
public
)
)
!=
SLURM_OPENSSL_VERIFIED
)
{
ERR_print_errors_fp
(
stderr
);
slurm_seterrno
(
ESLURMD_OPENSSL_ERROR
)
;
return
SLURM_ERROR
;
}
return
SLURM_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
src/common/credential_utils.h
0 → 100644
+
28
−
0
View file @
8a1712b3
#ifndef _CREDENTIAL_UTILS_H
#define _CREDENTIAL_UTILS_H
#include
<stdio.h>
#include
<openssl/rsa.h>
#include
<openssl/evp.h>
#include
<openssl/objects.h>
#include
<openssl/x509.h>
#include
<openssl/err.h>
#include
<openssl/pem.h>
#include
<openssl/ssl.h>
#include
<src/common/slurm_protocol_api.h>
enum
key_type
{
SIGNER_PRIVATE_KEY
,
VERIFIER_PUBLIC_KEY
}
;
enum
{
SLURM_OPENSSL_SIGNED
=
1
}
;
enum
{
SLURM_OPENSSL_VERIFIED
=
1
}
;
typedef
struct
credential_tools_ctx
{
enum
key_type
;
unsigned
int
key_length
;
union
key
{
EVP_PKEY
*
private
;
EVP_PKEY
*
public
;
}
key
;
}
credential_tools_ctx_t
;
#endif
This diff is collapsed.
Click to expand it.
src/slurmd/Makefile.am
+
2
−
2
View file @
8a1712b3
...
@@ -13,6 +13,6 @@ slurmd_SOURCES = slurmd.c \
...
@@ -13,6 +13,6 @@ slurmd_SOURCES = slurmd.c \
read_proc.c
\
read_proc.c
\
task_mgr.c
\
task_mgr.c
\
shmem_struct.c
\
shmem_struct.c
\
circular_buffer.c
circular_buffer.c
\
credential_utils.c
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