Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyMusatkin committed Nov 19, 2024
1 parent 87720d1 commit 8a052d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
13 changes: 4 additions & 9 deletions source/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,14 @@ PyObject *aws_py_rsa_private_key_from_der_data(PyObject *self, PyObject *args) {

size_t decoded_len = 0;
if (aws_base64_compute_decoded_len(&der_data_cur, &decoded_len)) {
//PyErr_AwsLastError();
//PyErr_SetString(PyExc_ValueError, "Invalid len");
PyErr_Format(PyExc_ValueError, "Invalid len %zu", der_data_cur.len);
PyErr_AwsLastError();
goto on_done;
}

aws_byte_buf_init(&decoded_buffer, allocator, decoded_len);

if (aws_base64_decode(&der_data_cur, &decoded_buffer)) {
//PyErr_AwsLastError();
PyErr_Format(PyExc_ValueError, "Invalid len decoded %zu", decoded_len);
PyErr_AwsLastError();
goto on_done;
}

Expand Down Expand Up @@ -417,8 +414,7 @@ PyObject *aws_py_rsa_public_key_from_der_data(PyObject *self, PyObject *args) {

size_t decoded_len = 0;
if (aws_base64_compute_decoded_len(&der_data_cur, &decoded_len)) {
//PyErr_AwsLastError();
PyErr_Format(PyExc_ValueError, "Invalid len %zu", der_data_cur.len);
PyErr_AwsLastError();
goto on_done;
}

Expand All @@ -434,8 +430,7 @@ PyObject *aws_py_rsa_public_key_from_der_data(PyObject *self, PyObject *args) {
struct aws_rsa_key_pair *key_pair = aws_rsa_key_pair_new_from_public_key_pkcs1(allocator, raw_der);

if (key_pair == NULL) {
//PyErr_AwsLastError();
PyErr_Format(PyExc_ValueError, "Invalid len decoded %zu", decoded_len);
PyErr_AwsLastError();
goto on_done;
}

Expand Down
11 changes: 0 additions & 11 deletions test/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@
'xgMJci1Irh66xVZQ9aT2OZwb0TXglULm+b8HM+GKHgoTMwr9gAGpFDoYi22PvxC/'
'cqKHKIaYw7KNOPwImzQ6cp5oQJTAPQKRUwIDAQAB')

RSA_PUBLIC_KEY_DER_BOTO3 = ('MIIBCgKCAQEAmC9Sp2vAK8r/B+5SvW4iMwU1wqwMISzuJqsFLLp6b/'
'shkeDSN+quDFn2ngSyd4dzut0Uk2/hshFWQhXhutmrnHZf4jx2ri1I'
'AEV3f8/f8o/sajMtupD5HTltyXhQIL8Dzcprq4GyXYKAhD+W9O3GDU'
'uMnP6aTbjMO2kOmE4GedA+RU+9L3AI/CFg5zgnzpQ3CCnCxrDK/ARa'
'E4mB5L6BvqzkyEo6jGi1OdJgWF/rJGNud2mjsDh95LmN+i0XGqDqw+'
'3m4AyRBzerSMnMVxzBaJZ835Qyuht2bOp30CpGvPMuPQhQoYJ9QKoPU8'
'a3DYFk8c6DCZA9UqPQG7Q4ayIQiQIDAQAB')

RSA_PRIVATE_KEY_DER = ('MIIEowIBAAKCAQEAxaEsLWE2t3kJqsF1sFHYk7rSCGfGTSDa+3r5typT0cb/TtJ9'
'89C8dLcfInx4Dxq0ewo6NOxQ/TD8JevUda86jSh1UKEQUOl7qy+QwOhFMpwHq/uO'
'gMy5khDDLlkxD5U32RrDfqLK+4WUDapHlQ6g+E6wS1j1yDRoTZJk3WnTpR0sJHst'
Expand Down Expand Up @@ -241,9 +233,6 @@ def test_rsa_load_error(self):
with self.assertRaises(ValueError):
RSA.new_public_key_from_pem_data(RSA_PRIVATE_KEY_PEM)

def test_does_it_load(self):
RSA.new_public_key_from_der_data(RSA_PUBLIC_KEY_DER_BOTO3)

def test_rsa_signing_verify_fail(self):
h = Hash.sha256_new()
h.update(b'totally original test string')
Expand Down

0 comments on commit 8a052d6

Please sign in to comment.