Fix SSHFP
This commit is contained in:
parent
a16cd9dd21
commit
ff49ac8f24
11
buffer.js
11
buffer.js
@ -66,6 +66,16 @@ function hexToBuffer (hexStr) {
|
||||
return bytes
|
||||
}
|
||||
|
||||
// Convert Uint8Array to hex string
|
||||
function bufferToHex (buf) {
|
||||
let hex = ''
|
||||
for (let i = 0; i < buf.length; i++) {
|
||||
const byte = buf[i]
|
||||
hex += (byte < 16 ? '0' : '') + byte.toString(16)
|
||||
}
|
||||
return hex.toUpperCase()
|
||||
}
|
||||
|
||||
// Convert Uint8Array to string
|
||||
function bufferToString (buf, encoding, start, end) {
|
||||
encoding = encoding || 'utf-8'
|
||||
@ -179,6 +189,7 @@ module.exports = {
|
||||
stringToBuffer,
|
||||
base64ToBuffer,
|
||||
hexToBuffer,
|
||||
bufferToHex,
|
||||
bufferToString,
|
||||
writeString,
|
||||
byteLength,
|
||||
|
||||
5
index.js
5
index.js
@ -15,7 +15,8 @@ const {
|
||||
readUInt32BE,
|
||||
writeUInt32BE,
|
||||
bufferCopy,
|
||||
bufferConcat
|
||||
bufferConcat,
|
||||
bufferToHex
|
||||
} = require('./buffer')
|
||||
|
||||
const types = require('./types')
|
||||
@ -1368,7 +1369,7 @@ rsshfp.decode = function decode (buf, offset) {
|
||||
offset += 1
|
||||
|
||||
const fingerprintLength = rsshfp.getFingerprintLengthForHashType(record.hash)
|
||||
record.fingerprint = buf.slice(offset, offset + fingerprintLength).toString('hex').toUpperCase()
|
||||
record.fingerprint = bufferToHex(buf.slice(offset, offset + fingerprintLength))
|
||||
offset += fingerprintLength
|
||||
rsshfp.decode.bytes = offset - oldOffset
|
||||
return record
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user