Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add req to OpenSSL CLI tool #2284

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9ea96a9
initial req tooling
smittals2 Mar 17, 2025
113e9ac
more stuff
smittals2 Mar 18, 2025
e9e7d2c
add prompting for password and cert/csr fields
smittals2 Mar 19, 2025
3a7ea54
add extensions and serial number support
smittals2 Mar 19, 2025
6af4cf0
consolidates csr extensions
smittals2 Mar 20, 2025
22eaa08
add testing and fix indents
smittals2 Mar 20, 2025
4ef7300
Merge branch 'main' into openssl_req
smittals2 Mar 20, 2025
8cf82d2
bump number of tools
smittals2 Mar 20, 2025
a8750f6
minor bugs
smittals2 Mar 21, 2025
d5b0b92
testing changes for CI
smittals2 Mar 24, 2025
a28b882
fix how we create tmp dir to avoid race condition
smittals2 Mar 24, 2025
2a5d58c
use diff var name
smittals2 Mar 24, 2025
3a265a4
ci stuff
smittals2 Mar 24, 2025
f2fa7d3
add back accidentally deleted function
smittals2 Mar 24, 2025
08d3259
ci failures
smittals2 Mar 26, 2025
5911d25
add declaration for printo func
smittals2 Mar 26, 2025
cb8a4f9
provide a custom config file for Openssl
smittals2 Mar 26, 2025
c0c8a66
use rand_bytes instead of processid/timestamp for temp dir name
smittals2 Mar 26, 2025
0a47063
remoe erroneous file from last commit
smittals2 Mar 26, 2025
a7d386e
pr comments
smittals2 Mar 27, 2025
468dd26
pr comments
smittals2 Mar 27, 2025
3945dfb
using union to convert between uint8_t and uint64_t
smittals2 Mar 27, 2025
af2f1cd
Merge branch 'main' into openssl_req
smittals2 Mar 28, 2025
5cb5f30
fix formatting with clang-format, minor PR comments
smittals2 Mar 28, 2025
101dfec
Merge branch 'main' into openssl_req
smittals2 Mar 28, 2025
dba74b4
move DSA macro to public header and modify gen key comments
smittals2 Mar 28, 2025
3f3ac0c
update spacing
smittals2 Mar 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions crypto/dsa/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ struct dsa_st {
CRYPTO_EX_DATA ex_data;
};

#define OPENSSL_DSA_MAX_MODULUS_BITS 10000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes seem to have been leaked over from 0c97337

Copy link
Contributor Author

@smittals2 smittals2 Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes sorry, I was addressing a comment from the PR for that commit. I merged it in without the change so I could get it in for the release.

The define is moved to public header, and generate_key comment is updated - no functional changes.

Comment on PR: #2293 (comment)


// dsa_check_key performs cheap self-checks on |dsa|, and ensures it is within
// DoS bounds. It returns one on success and zero on error.
int dsa_check_key(const DSA *dsa);
Expand Down
31 changes: 20 additions & 11 deletions crypto/test/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#include "test_util.h"

#include <ostream>
#include <inttypes.h>

#include <openssl/err.h>

#include "../internal.h"
#include "openssl/pem.h"
#include "openssl/rand.h"


void hexdump(FILE *fp, const char *msg, const void *in, size_t len) {
Expand Down Expand Up @@ -166,27 +168,33 @@ size_t createTempFILEpath(char buffer[PATH_MAX]) {
}

size_t createTempDirPath(char buffer[PATH_MAX]) {
char pathname[PATH_MAX];
char tempdir[PATH_MAX];

if (0 == GetTempPathA(PATH_MAX, pathname)) {
char temp_path[PATH_MAX];
union {
uint8_t bytes[8];
uint64_t value;
} random_bytes;

// Get the temporary path
if (0 == GetTempPathA(PATH_MAX, temp_path)) {
return 0;
}

// Generate a unique name using Windows API
if (0 == GetTempFileNameA(pathname, "awslctestdir", 0, tempdir)) {
if (!RAND_bytes(random_bytes.bytes, sizeof(random_bytes.bytes))) {
return 0;
}

// Delete the file that GetTempFileNameA created
DeleteFileA(tempdir);
int written = snprintf(buffer, PATH_MAX, "%s\\awslctest_%" PRIX64, temp_path, random_bytes.value);

if (!CreateDirectoryA(tempdir, NULL)) {
// Check for truncation of dirname
if (written < 0 || written >= PATH_MAX) {
return 0;
}

strncpy(buffer, tempdir, PATH_MAX);
return strnlen(buffer, PATH_MAX);
if (!CreateDirectoryA(buffer, NULL)) {
return 0;
}

return (size_t)written;
}

FILE* createRawTempFILE() {
Expand All @@ -196,6 +204,7 @@ FILE* createRawTempFILE() {
}
return fopen(filename, "w+b");
}

#else
#include <cstdlib>
#include <unistd.h>
Expand Down
6 changes: 4 additions & 2 deletions include/openssl/dsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
extern "C" {
#endif

#define OPENSSL_DSA_MAX_MODULUS_BITS 10000


// DSA contains functions for signing and verifying with the Digital Signature
// Algorithm.
Expand Down Expand Up @@ -187,8 +189,8 @@ OPENSSL_EXPORT DSA *DSAparams_dup(const DSA *dsa);
// Key generation.

// DSA_generate_key generates a public/private key pair in |dsa|, which must
// already have parameters setup. It returns one on success and zero on
// error.
// already have parameters setup. Only supports generating upto |OPENSSL_DSA_MAX_MODULUS_BITS|
// bit keys. It returns one on success and zero on error.
OPENSSL_EXPORT int DSA_generate_key(DSA *dsa);


Expand Down
3 changes: 3 additions & 0 deletions tool-openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_executable(
crl.cc
dgst.cc
rehash.cc
req.cc
rsa.cc
s_client.cc
tool.cc
Expand Down Expand Up @@ -83,6 +84,8 @@ if(BUILD_TESTING)
dgst_test.cc
rehash.cc
rehash_test.cc
req.cc
req_test.cc
rsa.cc
rsa_test.cc
s_client.cc
Expand Down
4 changes: 4 additions & 0 deletions tool-openssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ bool CRLTool(const args_list_t &args);
bool dgstTool(const args_list_t &args);
bool md5Tool(const args_list_t &args);
bool RehashTool(const args_list_t &args);
bool reqTool(const args_list_t &args);
bool rsaTool(const args_list_t &args);
bool SClientTool(const args_list_t &args);
bool VerifyTool(const args_list_t &args);
bool VersionTool(const args_list_t &args);
bool X509Tool(const args_list_t &args);

// Req Tool Utilities
bssl::UniquePtr<X509_NAME> parse_subject_name(std::string &subject_string);


// Rehash tool Utils
typedef struct hash_entry_st { // Represents a single certificate/CRL file
Expand Down
Loading
Loading