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

PEM to JWK converters #4359

Merged
merged 42 commits into from
Oct 20, 2022
Merged

PEM to JWK converters #4359

merged 42 commits into from
Oct 20, 2022

Conversation

jumaffre
Copy link
Contributor

@jumaffre jumaffre commented Oct 17, 2022

Resolves #4321

This PR adds C++ and JS/TS API to convert a public/private EC/RSA key from PEM to JSON Web Key (JWK). Note that this uses the Python JWCrypto package to compare the results to a well-known implementation.

TODO:

  • TS polyfill

@jumaffre jumaffre changed the title Js pem to jwk PEM to JWK converters Oct 17, 2022
@ghost
Copy link

ghost commented Oct 18, 2022

js_pem_to_jwk@51770 aka 20221020.42 vs main ewma over 20 builds from 51323 to 51756

Click to see table

main

build_id build_number tpcc_virtual_cft^ tpcc_virtual_cft_mem ls_virtual_cft^ ls_virtual_cft_mem ls_jwt_virtual_cft^ ls_jwt_virtual_cft_mem tpcc_sgx_cft^ tpcc_sgx_cft_mem ls_js_virtual_cft^ ls_js_virtual_cft_mem ls_full_js_virtual_cft^ ls_full_js_virtual_cft_mem ls_sgx_cft^ ls_sgx_cft_mem ls_js_jwt_virtual_cft^ ls_js_jwt_virtual_cft_mem ls_jwt_sgx_cft^ ls_jwt_sgx_cft_mem ls_js_sgx_cft^ ls_js_sgx_cft_mem hist_sgx_cft^ ls_full_js_sgx_cft^ ls_full_js_sgx_cft_mem ls_js_jwt_sgx_cft^ ls_js_jwt_sgx_cft_mem RB put (/s)^ CHAMP put (/s)^ RB get (/s)^ CHAMP get (/s)^
51323 20221017.3 11697.2 0 43984.1 0 10061.3 0 6253.13 8.3497e+07 4390.77 0 3444.48 0 19369.6 1.6126e+07 3280.7 0 5600.96 1.56017e+07 2434.56 9.57242e+06 23812.4 2039.86 9.31027e+06 1907.97 9.04813e+06 891786 1.36989e+06 9.20028e+06 3.58042e+07
51356 20221017.18 10476.1 0 42021.6 0 10516.1 0 6294.69 8.29727e+07 4260.13 0 3424.86 0 19384.8 1.6126e+07 3349.05 0 5564.24 1.56017e+07 2427.01 9.83456e+06 28408.8 2032.63 9.57242e+06 1879.5 9.31027e+06 902005 1.36871e+06 9.25445e+06 3.58042e+07
51369 20221017.23 10815.5 0 43886 0 10496.8 0 6182.92 8.3497e+07 4265.57 0 3591.34 0 20141.6 1.63882e+07 3287.98 0 5526.98 1.50774e+07 2428.79 9.57242e+06 31812.7 2033.49 1.35046e+07 1869.38 9.04813e+06 892565 1.36669e+06 9.15508e+06 3.48887e+07
51401 20221017.36 11574 0 42017.4 0 10681.1 0 6401.49 8.32349e+07 4325.12 0 3465.53 0 19869.8 1.6126e+07 3295.72 0 5662.52 1.53396e+07 2430.97 9.57242e+06 24574.1 2063.81 9.31027e+06 1835.87 9.31027e+06 903431 1.36769e+06 9.25436e+06 3.55556e+07
51413 20221018.3 11013.5 0 43526 0 10297.9 0 6278.03 8.21863e+07 4667.91 0 3685.52 0 19757.1 1.6126e+07 3264.67 0 5570.73 1.56017e+07 2430.11 1.00967e+07 31329.2 2027.11 9.31027e+06 1869.16 9.04813e+06 902039 1.34692e+06 9.26693e+06 3.57411e+07
51429 20221018.9 11110.8 0 40278 0 10337.7 0 6224.69 8.29727e+07 4266.39 0 3578.13 0 19543 1.63882e+07 3221.39 0 5628.46 1.58639e+07 2438.33 9.57242e+06 26283.5 2036.01 9.31027e+06 1849.43 9.31027e+06 907997 1.36879e+06 9.21269e+06 3.49488e+07
51448 20221018.17 10970.3 0 40387.1 0 10141 0 6358.96 8.29727e+07 4816.31 0 3583.18 0 20736.7 1.6126e+07 3365.91 0 6546.68 1.58639e+07 2491.75 9.83456e+06 27143.6 2114.99 9.57242e+06 2043.52 9.04813e+06 896039 1.36332e+06 9.17555e+06 3.58042e+07
51462 20221018.22 11528.7 0 40554.5 0 10737.9 0 6364.65 8.21863e+07 4313.46 0 3591.18 0 20872.7 1.63882e+07 3248.26 0 6477.21 1.53396e+07 2504.11 9.57242e+06 27237.4 2088.99 9.31027e+06 2108.59 9.04813e+06 905588 1.38284e+06 9.26269e+06 3.58669e+07
51484 20221018.31 11594.7 0 40594.8 0 10515.9 0 6322.76 8.29727e+07 4413.7 0 3471.44 0 20910.3 1.6126e+07 3375.31 0 6470.15 1.58639e+07 2541.74 1.00967e+07 28596.7 2082.94 9.57242e+06 1993.75 9.31027e+06 886076 1.34268e+06 9.00216e+06 3.5128e+07
51516 20221018.43 11003.7 0 41607.1 0 10624.7 0 6379.93 8.37592e+07 4282.55 0 3524.01 0 20709.1 1.71746e+07 3224.96 0 6410.82 1.53396e+07 2492.92 9.83456e+06 23047.8 2081.91 9.57242e+06 1992.92 9.04813e+06 885966 1.395e+06 9.17974e+06 3.58669e+07
51542 20221018.51 11060 0 40657.4 0 10727.4 0 6396.41 8.3497e+07 4326.02 0 3603.46 0 20985.3 1.6126e+07 3255.85 0 6446.03 1.58639e+07 2499.1 9.83456e+06 25612.3 2154.7 9.57242e+06 1998.32 9.04813e+06 881385 1.36551e+06 9.27532e+06 3.58663e+07
51552 20221018.55 8720.44 0 34911.7 0 9261.82 0 6425.99 8.3497e+07 4085.74 0 3347.54 0 20823.3 1.63882e+07 3197.54 0 6505.01 1.58639e+07 2485.32 1.00967e+07 24649.6 2095.18 9.31027e+06 2010.82 9.31027e+06 917639 1.37977e+06 9.27952e+06 3.63121e+07
51560 20221019.3 11252.2 0 37041 0 10152.8 0 6359.85 8.3497e+07 4368.85 0 3403.13 0 20749 1.63882e+07 3365.06 0 6418.94 1.58639e+07 2490.69 9.83456e+06 28778.6 2105.81 9.31027e+06 2036.1 9.04813e+06 908117 1.37624e+06 9.41168e+06 3.66362e+07
51568 20221019.7 10865.4 0 37837.3 0 10050.4 0 5745.73 8.37592e+07 4574.09 0 3426.37 0 17946.8 1.71746e+07 3507.21 0 6045.94 1.53396e+07 2356.59 9.83456e+06 21129.7 1999.41 1.08831e+07 1975.93 9.31027e+06 905101 1.37374e+06 9.29629e+06 3.54933e+07
51596 20221019.17 9898.13 0 36578.3 0 9638.42 0 5697 8.29727e+07 4265.05 0 3362.88 0 17157.3 1.69124e+07 3199.59 0 6161.39 1.56017e+07 2411.73 9.57242e+06 23518.8 2017.64 9.31027e+06 1931.15 9.31027e+06 911715 1.37145e+06 9.17148e+06 3.58669e+07
51626 20221019.27 11126.6 0 42087 0 10128.4 0 5640.83 8.29727e+07 4248.36 0 3590.06 0 17643 1.58639e+07 3264.35 0 6155.07 1.53396e+07 2345.98 9.57242e+06 27871.7 1981.41 9.57242e+06 1930.93 9.04813e+06 911634 1.36897e+06 9.06993e+06 3.51884e+07
51650 20221020.3 11472.4 0 41541.8 0 10031.5 0 5786.4 8.27106e+07 4301.53 0 3539.77 0 18023.8 1.58639e+07 3209.56 0 6135.44 1.56017e+07 2369.1 9.57242e+06 28253.1 1991.09 9.57242e+06 1934.73 9.04813e+06 905029 1.39168e+06 9.22934e+06 3.56174e+07
51670 20221020.10 11143.3 0 42769.6 0 10308.8 0 5718.02 8.32349e+07 4367.85 0 3535.13 0 17836.8 1.69124e+07 3305.8 0 6100.99 1.58639e+07 2367.39 9.57242e+06 29115.5 1941.56 9.57242e+06 1923.17 9.31027e+06 891086 1.38743e+06 9.18789e+06 3.58036e+07
51694 20221020.18 10569.2 0 40721.7 0 10547.6 0 5528.74 8.29727e+07 4237.22 0 3461.38 0 17709.3 1.63882e+07 3256.86 0 6105.49 1.56017e+07 2315.14 9.83456e+06 20991.9 1981.1 9.57242e+06 1918.74 9.31027e+06 904667 1.39054e+06 9.45513e+06 3.60557e+07
51756 20221020.38 11145.5 0 43326.1 0 10685.5 0 5617 8.32349e+07 4313.24 0 3571.63 0 17658.7 1.66503e+07 3227.65 0 6143.66 1.53396e+07 2350.65 9.83456e+06 24478.8 2019.9 9.31027e+06 1928.99 9.57242e+06 897688 1.33107e+06 9.0981e+06 3.54939e+07

js_pem_to_jwk

build_id build_number tpcc_virtual_cft^ tpcc_virtual_cft_mem ls_virtual_cft^ ls_virtual_cft_mem ls_jwt_virtual_cft^ ls_jwt_virtual_cft_mem ls_js_virtual_cft^ ls_js_virtual_cft_mem ls_full_js_virtual_cft^ ls_full_js_virtual_cft_mem ls_js_jwt_virtual_cft^ ls_js_jwt_virtual_cft_mem hist_sgx_cft^ tpcc_sgx_cft^ tpcc_sgx_cft_mem ls_sgx_cft^ ls_sgx_cft_mem ls_jwt_sgx_cft^ ls_jwt_sgx_cft_mem ls_js_sgx_cft^ ls_js_sgx_cft_mem ls_full_js_sgx_cft^ ls_full_js_sgx_cft_mem ls_js_jwt_sgx_cft^ ls_js_jwt_sgx_cft_mem RB put (/s)^ CHAMP put (/s)^ RB get (/s)^ CHAMP get (/s)^
51603 20221019.19 11089.1 0 43326.1 0 10423.4 0 4373.98 0 3542.88 0 3313.94 0 25132 5660.1 8.29727e+07 17814.4 1.6126e+07 6094.13 1.56017e+07 2353.93 9.57242e+06 2042.99 9.31027e+06 1929.37 9.57242e+06 901720 1.38847e+06 9.25014e+06 3.58042e+07
51708 20221020.22 nan nan nan nan nan nan nan nan nan nan nan nan 17316.8 5687.43 8.42835e+07 17692.5 1.63882e+07 6036.61 1.58639e+07 2359.04 9.57242e+06 1983.69 9.31027e+06 1926.78 9.04813e+06 900253 1.37523e+06 9.25432e+06 3.58669e+07
51711 20221020.23 10522.7 0 40452.9 0 10590.9 0 4253.72 0 3469.84 0 3363.32 0 29902 5697.87 8.3497e+07 17633.2 1.6126e+07 6056.11 1.56017e+07 2356.54 9.57242e+06 1986.55 9.31027e+06 1925.43 9.04813e+06 904468 1.37615e+06 9.22514e+06 3.58042e+07
51722 20221020.27 10781.5 0 41589 0 10446.6 0 4271.2 0 3337.01 0 3292.34 0 23305.4 5748.98 8.3497e+07 17715.5 1.63882e+07 6094.86 1.53396e+07 2368.21 9.57242e+06 1948.5 9.57242e+06 1923.3 9.31027e+06 908520 1.36414e+06 9.26693e+06 3.54939e+07
51770 20221020.42 11070.1 0 41808 0 10458.3 0 4234.28 0 3394.25 0 3506.66 0 30371.8 5693.65 8.40213e+07 17657.2 1.69124e+07 6174.2 1.56017e+07 2348.69 9.57242e+06 1984.18 9.57242e+06 1926.47 9.31027e+06 887266 1.37053e+06 9.27112e+06 3.56794e+07

images

@jumaffre jumaffre marked this pull request as ready for review October 18, 2022 15:43
@jumaffre jumaffre requested a review from a team October 18, 2022 15:43
Copy link

@wintersteiger wintersteiger left a comment

Choose a reason for hiding this comment

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

LGTM! Somebody already said this somewhere and I agree, Curve25519 would be a worthwhile addition.

include/ccf/crypto/jwk.h Show resolved Hide resolved
include/ccf/crypto/jwk.h Show resolved Hide resolved
tests/js-modules/modules.py Show resolved Hide resolved
tests/js-modules/modules.py Show resolved Hide resolved
include/ccf/crypto/jwk.h Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a PEM public key to JWK converter in the JS API
3 participants