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 PEM support #587

Merged
merged 51 commits into from
Aug 20, 2024
Merged

Add PEM support #587

merged 51 commits into from
Aug 20, 2024

Commits on Aug 20, 2024

  1. add OpenSSH Private Key decryption demo

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    bee3ad2 View commit details
    Browse the repository at this point in the history
  2. add rsa-support

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    fec3d45 View commit details
    Browse the repository at this point in the history
  3. add ecdsa key support

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    2ff20d7 View commit details
    Browse the repository at this point in the history
  4. add ssh private testkeys

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    e0046fb View commit details
    Browse the repository at this point in the history
  5. refactor & clean-up

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    350fbc6 View commit details
    Browse the repository at this point in the history
  6. use updated API

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    a301ea1 View commit details
    Browse the repository at this point in the history
  7. re-factor openssh-privkey demo into library functions

    This adds two new API functions
    * `pem_decode_openssh()`
    * `pem_decode_openssh_filehandle()`
    
    It also introduces the following two new types:
    * a new union type `ltc_pka_key` which can hold any PKA key type.
    * a `password_ctx` type with a callback to retrieve a password
      if necessary.
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    cf71fff View commit details
    Browse the repository at this point in the history
  8. rename file

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    69c93a8 View commit details
    Browse the repository at this point in the history
  9. add pk_get_oid_from_asn1()

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    35c306f View commit details
    Browse the repository at this point in the history
  10. add der_flexi_sequence_cmp()

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    18baa14 View commit details
    Browse the repository at this point in the history
  11. add LTC_OID_MAX_STRLEN

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    b8cb13f View commit details
    Browse the repository at this point in the history
  12. add pkcs8_get_children()

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    e9f1db1 View commit details
    Browse the repository at this point in the history
  13. re-factor PKCS#8 API a bit

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    3f6f885 View commit details
    Browse the repository at this point in the history
  14. add support for regular PEM files

    This adds support to decode plain and encrypted PEM files.
    
    Either in OpenSSL specific format or PKCS#8
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    f036a47 View commit details
    Browse the repository at this point in the history
  15. add PEM tests

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    370457f View commit details
    Browse the repository at this point in the history
  16. add dsa_import_pkcs8()

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    464c9b1 View commit details
    Browse the repository at this point in the history
  17. add DSA support to PEM decoder

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    22a952b View commit details
    Browse the repository at this point in the history
  18. Verify that the imported keys match

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    d1e48df View commit details
    Browse the repository at this point in the history
  19. add file-iterator to test_process_dir()

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    a76447f View commit details
    Browse the repository at this point in the history
  20. also test FILE-based PEM API's

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    3e981af View commit details
    Browse the repository at this point in the history
  21. split-up into multiple C files

    ... and slightly optimize multiple things, e.g. `DEK-Info` decoding
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    87a1758 View commit details
    Browse the repository at this point in the history
  22. add support for DH keys

    Signed-off-by: Steffen Jaeckel <[email protected]>
    
    # Conflicts:
    #	src/pk/dh/dh_import.c
    #	src/pk/dh/dh_set.c
    #	src/pk/dh/dh_set_pg_dhparam.c
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    26fbebb View commit details
    Browse the repository at this point in the history
  23. disable PEM support on MSVC

    If someone wants to fix builds on MSVC, please step forward. Until then
    the library can still be used on Windows via `mingw-gcc`.
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    5523ead View commit details
    Browse the repository at this point in the history
  24. clean-up a bit

    * more `const` correctness
    * take `LTC_NO_FILE` into account
    * only declare `extern` variables where they're required
    * ensure keys don't contain stale data
    * ensure input arguments are valid
    * add `CRYPT_PW_CTX_MISSING` error code
    * fix documentation
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    4e46f82 View commit details
    Browse the repository at this point in the history
  25. introduce pka_key_free()

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    6515822 View commit details
    Browse the repository at this point in the history
  26. Update docs

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    39d4b08 View commit details
    Browse the repository at this point in the history
  27. distinguish between Ed25519 and X25519

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    661f584 View commit details
    Browse the repository at this point in the history
  28. Add support for aes256-ctr encrypted SSH keys

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    6c24c5c View commit details
    Browse the repository at this point in the history
  29. Use the public key contained within the ssh key

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    9333d5c View commit details
    Browse the repository at this point in the history
  30. Add "Enter passphrase" support to openssh-privkey

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    934abdd View commit details
    Browse the repository at this point in the history
  31. Refactor some of the ECC import internals

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    5d86589 View commit details
    Browse the repository at this point in the history
  32. Add support for more algos of encrypted PEM files

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    f6497d2 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    cda6211 View commit details
    Browse the repository at this point in the history
  34. Add support for importing PEM public keys

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    23eb8f9 View commit details
    Browse the repository at this point in the history
  35. Per default support PEM line lengths up to 80 chars

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    928c476 View commit details
    Browse the repository at this point in the history
  36. Add more SSH key tests

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    ca7b4ee View commit details
    Browse the repository at this point in the history
  37. Calm old Valgrind ...

    Valgrind 3.15.0 on Ubuntu 20.04 reports a false positive [0]
    
    ```
    ==7922== Conditional jump or move depends on uninitialised value(s)
    ==7922==    at 0x461F0C: s_decode_header (pem_ssh.c:316)
    [...]
    ```
    
    Simply suppress this false positive.
    
    [0] https://github.com/libtom/libtomcrypt/actions/runs/6507805191/job/17676616149?pr=587
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    7b5d85d View commit details
    Browse the repository at this point in the history
  38. Add support for more PEM file types + some fixes

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    8d19047 View commit details
    Browse the repository at this point in the history
  39. Add generic PEM decode APIs

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    fe3b3e6 View commit details
    Browse the repository at this point in the history
  40. Move password buffer into the library

    The design before was not completely fine. The user had to allocate the
    buffer and passed ownership to the library.
    As of [0] this seems to be a problem in some environments.
    
    [0] #587 (comment)
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    03515d5 View commit details
    Browse the repository at this point in the history
  41. Make everything compile on MSVC

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    9db30df View commit details
    Browse the repository at this point in the history
  42. Revert "Move password buffer into the library"

    This reverts commit d840323
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    02cb0c4 View commit details
    Browse the repository at this point in the history
  43. Add free() function to password_ctx

    The user can now pass a `free()` function pointer that will be used to
    free the memory that has been allocated by the `callback()`.
    If `free()` is NULL, the library will still call `XFREE()`.
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    9579022 View commit details
    Browse the repository at this point in the history
  44. Update docs

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    65e05bf View commit details
    Browse the repository at this point in the history
  45. Add support for more types of encrypted PEM files

    1. ChaCha20, two-key 3DES and DES-X encrypted OpenSSL PEM files
    
    2. AES-GCM and Chacha20+Poly1305 encrypted SSH keys
    
    * OpenSSH uses a slightly different algorithm for its
      `[email protected]` than defined in the RFC.
      Therefore add an `openssh_compat` flag to
      `chacha20poly1305_state`.
    * Add the option to give a 16byte IV and no counter, when calling
      `chacha20poly1305_memory()`
    * Add support for DES-X
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    c0be0aa View commit details
    Browse the repository at this point in the history
  46. Add support for reading authorized_keys files

    This also changes the requirements when calling `ecc_find_curve()` that
    the `cu` argument can be NULL.
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    478f43f View commit details
    Browse the repository at this point in the history
  47. Update makefiles

    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    ec8ffbb View commit details
    Browse the repository at this point in the history
  48. Fix make tvs, add make pr-check

    Fixup of 5ad1681
    
    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    5dec1ee View commit details
    Browse the repository at this point in the history
  49. Add support for CFB1 and CFB8

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    cf79fac View commit details
    Browse the repository at this point in the history
  50. We can now also decrypt PEM files encrypted in CFB1 and CFB8 mode

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    2613264 View commit details
    Browse the repository at this point in the history
  51. Update docs

    Signed-off-by: Steffen Jaeckel <[email protected]>
    sjaeckel committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    2594f3a View commit details
    Browse the repository at this point in the history