Update cipher/hmac descriptions as well as the algorithms themselves.

This commit is contained in:
Tony Garnock-Jones 2011-10-20 13:40:09 -04:00
parent 2de68a7ec0
commit 526d3b9afe
1 changed files with 26 additions and 28 deletions

View File

@ -688,35 +688,33 @@
(define enc (if c2s c2s-enc s2c-enc)) (define enc (if c2s c2s-enc s2c-enc))
(define mac (if c2s c2s-mac s2c-mac)) (define mac (if c2s c2s-mac s2c-mac))
(define zip (if c2s c2s-zip s2c-zip)) (define zip (if c2s c2s-zip s2c-zip))
(struct-copy stream-state state
[cipher (cond (define cipher-description
((assq enc supported-crypto-algorithms) => (cond
(lambda (entry) ((assq enc supported-crypto-algorithms) => cadr)
(define c (cadr entry))
(define key (derive-key (if c2s #"C" #"D")
(supported-cipher-key-length c)))
(define iv (derive-key (if c2s #"A" #"B")
(supported-cipher-iv-length c)))
(define factory (supported-cipher-factory c))
;; (pretty-print `(,is-server? ,(if c2s 'c2s 's2c) ,enc
;; (key ,(hex key)) (iv ,(hex iv))))
(factory is-outbound? key iv)))
(else (disconnect-with-error SSH_DISCONNECT_KEY_EXCHANGE_FAILED (else (disconnect-with-error SSH_DISCONNECT_KEY_EXCHANGE_FAILED
"Could not find driver for encryption algorithm ~v" "Could not find driver for encryption algorithm ~v"
enc)))] enc))))
[hmac (cond (define cipher ((supported-cipher-factory cipher-description)
((assq mac supported-hmac-algorithms) => is-outbound?
(lambda (entry) (derive-key (if c2s #"C" #"D") (supported-cipher-key-length cipher-description))
(define h (cadr entry)) (derive-key (if c2s #"A" #"B") (supported-cipher-iv-length cipher-description))))
(define factory (supported-hmac-factory h))
(define key (derive-key (if c2s #"E" #"F") (define hmac-description
(supported-hmac-key-length h))) (cond
;; (pretty-print `(,is-server? ,(if c2s 'c2s 's2c) ,mac ((assq mac supported-hmac-algorithms) => cadr)
;; (key ,(hex key))))
(factory key)))
(else (disconnect-with-error SSH_DISCONNECT_KEY_EXCHANGE_FAILED (else (disconnect-with-error SSH_DISCONNECT_KEY_EXCHANGE_FAILED
"Could not find driver for HMAC algorithm ~v" "Could not find driver for HMAC algorithm ~v"
mac)))])) mac))))
(define hmac ((supported-hmac-factory hmac-description)
(derive-key (if c2s #"E" #"F") (supported-hmac-key-length hmac-description))))
(pretty-print `(,is-server? ,(if c2s 'c2s 's2c) ,enc ,mac))
(struct-copy stream-state state
[cipher cipher]
[cipher-description cipher-description]
[hmac hmac]
[hmac-description hmac-description]))
;; PacketHandler for handling SSH_MSG_KEXINIT. ;; PacketHandler for handling SSH_MSG_KEXINIT.
(define (handle-msg-kexinit packet message conn) (define (handle-msg-kexinit packet message conn)