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
|
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
|
// Convert Uint8Array to string
|
||||||
function bufferToString (buf, encoding, start, end) {
|
function bufferToString (buf, encoding, start, end) {
|
||||||
encoding = encoding || 'utf-8'
|
encoding = encoding || 'utf-8'
|
||||||
@ -179,6 +189,7 @@ module.exports = {
|
|||||||
stringToBuffer,
|
stringToBuffer,
|
||||||
base64ToBuffer,
|
base64ToBuffer,
|
||||||
hexToBuffer,
|
hexToBuffer,
|
||||||
|
bufferToHex,
|
||||||
bufferToString,
|
bufferToString,
|
||||||
writeString,
|
writeString,
|
||||||
byteLength,
|
byteLength,
|
||||||
|
|||||||
5
index.js
5
index.js
@ -15,7 +15,8 @@ const {
|
|||||||
readUInt32BE,
|
readUInt32BE,
|
||||||
writeUInt32BE,
|
writeUInt32BE,
|
||||||
bufferCopy,
|
bufferCopy,
|
||||||
bufferConcat
|
bufferConcat,
|
||||||
|
bufferToHex
|
||||||
} = require('./buffer')
|
} = require('./buffer')
|
||||||
|
|
||||||
const types = require('./types')
|
const types = require('./types')
|
||||||
@ -1368,7 +1369,7 @@ rsshfp.decode = function decode (buf, offset) {
|
|||||||
offset += 1
|
offset += 1
|
||||||
|
|
||||||
const fingerprintLength = rsshfp.getFingerprintLengthForHashType(record.hash)
|
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
|
offset += fingerprintLength
|
||||||
rsshfp.decode.bytes = offset - oldOffset
|
rsshfp.decode.bytes = offset - oldOffset
|
||||||
return record
|
return record
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user