algorithms.ts 878 B

1234567891011121314151617181920
  1. import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
  2. import { ALGORITHM_BLACKLIST, SSHAlgorithmType } from './api'
  3. // Counteracts https://github.com/mscdex/ssh2/commit/f1b5ac3c81734c194740016eab79a699efae83d8
  4. ALGORITHMS.DEFAULT_CIPHER.push('aes128-gcm')
  5. ALGORITHMS.DEFAULT_CIPHER.push('aes256-gcm')
  6. ALGORITHMS.SUPPORTED_CIPHER.push('aes128-gcm')
  7. ALGORITHMS.SUPPORTED_CIPHER.push('aes256-gcm')
  8. export const supportedAlgorithms: Record<string, string> = {}
  9. for (const k of Object.values(SSHAlgorithmType)) {
  10. const supportedAlg = {
  11. [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX',
  12. [SSHAlgorithmType.HOSTKEY]: 'SUPPORTED_SERVER_HOST_KEY',
  13. [SSHAlgorithmType.CIPHER]: 'SUPPORTED_CIPHER',
  14. [SSHAlgorithmType.HMAC]: 'SUPPORTED_MAC',
  15. }[k]
  16. supportedAlgorithms[k] = ALGORITHMS[supportedAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x)).sort()
  17. }