|
460 | 460 |
|
461 | 461 | # https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html |
462 | 462 | @testset "Encrypt" begin |
463 | | - if OpenSSL.version_number() ≥ v"3" |
464 | | - OpenSSL.load_legacy_provider() |
465 | | - end |
466 | 463 | evp_ciphers = [ |
467 | 464 | EvpEncNull(), |
468 | | - EvpBlowFishCBC(), # legacy |
469 | | - EvpBlowFishECB(), # legacy |
470 | 465 | #EvpBlowFishCFB(), // not supported |
471 | | - EvpBlowFishOFB(), # legacy |
472 | 466 | EvpAES128CBC(), |
473 | 467 | EvpAES128ECB(), |
474 | 468 | #EvpAES128CFB(), // not supported |
|
503 | 497 | end |
504 | 498 | end |
505 | 499 |
|
506 | | -@testset "EncryptCustomKey" begin |
507 | | - # EvpBlowFishECB is legacy, consider using EvpAES128ECB instead |
508 | | - if OpenSSL.version_number() ≥ v"3" |
509 | | - OpenSSL.load_legacy_provider() |
510 | | - end |
511 | | - evp_cipher = EvpBlowFishECB() |
512 | | - sym_key = random_bytes(evp_cipher.key_length ÷ 2) |
513 | | - init_vector = random_bytes(evp_cipher.init_vector_length ÷ 2) |
514 | | - |
515 | | - enc_evp_cipher_ctx = EvpCipherContext() |
516 | | - encrypt_init(enc_evp_cipher_ctx, evp_cipher, sym_key, init_vector) |
517 | | - |
518 | | - dec_evp_cipher_ctx = EvpCipherContext() |
519 | | - decrypt_init(dec_evp_cipher_ctx, evp_cipher, sym_key, init_vector) |
520 | | - |
521 | | - in_string = "OpenSSL Julia" |
522 | | - in_data = IOBuffer(in_string) |
523 | | - enc_data = IOBuffer() |
524 | | - |
525 | | - cipher(enc_evp_cipher_ctx, in_data, enc_data) |
526 | | - seek(enc_data, 0) |
527 | | - @show String(read(enc_data)) |
528 | | - seek(enc_data, 0) |
529 | | - |
530 | | - dec_data = IOBuffer() |
531 | | - cipher(dec_evp_cipher_ctx, enc_data, dec_data) |
532 | | - out_data = take!(dec_data) |
533 | | - out_string = String(out_data) |
534 | | - |
535 | | - @test in_string == out_string |
536 | | -end |
537 | | - |
538 | 500 | @testset "StackOf{X509Extension}" begin |
539 | 501 | ext1 = X509Extension("subjectAltName", "DNS:openssl.jl.com") |
540 | 502 | ext2 = X509Extension("keyUsage", "digitalSignature, keyEncipherment, keyAgreement") |
|
0 commit comments