Changeset 40254 in project


Ignore:
Timestamp:
07/04/21 13:15:38 (4 weeks ago)
Author:
Vasilij Schneidermann
Message:

openssl: Reorder port arguments for consistency

Location:
release/5/openssl/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • release/5/openssl/trunk/openssl.cipher.scm

    r40248 r40254  
    138138(define max-block-length EVP_MAX_BLOCK_LENGTH)
    139139
    140 (define-record cipher-context ptr tag-length)
     140(define-record cipher-context ptr mode tag-length)
    141141
    142142(define (cipher-context-free! context)
    143143  (and-let* ((ctx (cipher-context-ptr context)))
    144144    (EVP_CIPHER_CTX_free ctx)
     145    (cipher-context-mode-set! context #f)
    145146    (cipher-context-ptr-set! context #f)))
    146147
     
    150151    (when (not ctx)
    151152      (openssl-error 'cipher-context-allocate!))
    152     (set-finalizer! (make-cipher-context ctx #f) cipher-context-free!)))
     153    (set-finalizer! (make-cipher-context ctx #f #f) cipher-context-free!)))
    153154
    154155(define (cipher-context-unwrap! context)
     
    213214    (when (not (EVP_CipherInit_ex ctx cipher #f #f #f (mode->flag mode)))
    214215      (openssl-error 'cipher-context-init! (list cipher mode)))
     216    (cipher-context-mode-set! context mode)
    215217    (when (> key-length (blob-size key))
    216218      (openssl-type-error "effective key length <= key size" key-length (blob-size key)))
     
    293295    (when (not (aead-cipher? ctx))
    294296      (openssl-type-error 'cipher-context-get-tag "AEAD cipher" (cipher-name (EVP_CIPHER_CTX_cipher ctx))))
    295     (let ((tag-length (cipher-context-tag-length context)))
     297    (let ((mode (cipher-context-mode context))
     298          (tag-length (cipher-context-tag-length context)))
     299      (when (not mode)
     300        (openssl-type-error 'cipher-context-get-tag "initialized context" #f))
     301      (when (not (eqv? mode 'encrypt))
     302        (openssl-type-error 'cipher-context-get-tag "encrypt mode" mode))
    296303      (when (not tag-length)
    297304        (openssl-type-error 'cipher-context-get-tag "tag length to be set" #f))
     
    352359    (cipher-context-free! context)))
    353360
    354 (define (open-cipher-port out cipher key iv #!rest options)
     361(define (open-cipher-port cipher out key iv #!rest options)
    355362  (let ((context (cipher-context-allocate!)))
    356363    (apply cipher-context-init! context cipher key iv options)
  • release/5/openssl/trunk/openssl.digest.scm

    r40246 r40254  
    191191      ret)))
    192192
    193 (define (open-digest-port out digest)
     193(define (open-digest-port digest out #!rest options)
    194194  (let ((context (digest-context-allocate!)))
    195     (digest-context-init! context digest)
     195    (apply digest-context-init! context digest options)
    196196    (make-output-port
    197197     (lambda (str)
  • release/5/openssl/trunk/tests/cipher-test.scm

    r40246 r40254  
    3939              (call-with-output-string
    4040               (lambda (out)
    41                  (let ((out (open-cipher-port out aes-128-ecb key iv mode: 'encrypt)))
     41                 (let ((out (open-cipher-port aes-128-ecb out key iv mode: 'encrypt)))
    4242                   (display "secret" out)
    4343                   (close-output-port out))))))
    4444        (call-with-output-string
    4545         (lambda (out)
    46            (let ((out (open-cipher-port out aes-128-ecb key iv mode: 'decrypt)))
     46           (let ((out (open-cipher-port aes-128-ecb out key iv mode: 'decrypt)))
    4747             (display ciphertext out)
    4848             (close-output-port out))))))
  • release/5/openssl/trunk/tests/digest-test.scm

    r40246 r40254  
    3232      (call-with-output-string
    3333       (lambda (out)
    34          (let ((out (open-digest-port out md5)))
     34         (let ((out (open-digest-port md5 out)))
    3535           (display "" out)
    3636           (close-output-port out)))))
  • release/5/openssl/trunk/tests/manual/test-client.scm

    r40200 r40254  
    1515                                 sni-name: #t
    1616                                 verify?: #f)
    17                  (if (and in out)       ; Ugly, but necessary
     17                 (if (and in out) ; Ugly, but necessary
    1818                     (values in out)
    1919                     (error "You forgot to install the openssl egg."))))
Note: See TracChangeset for help on using the changeset viewer.