Presentation format encoding
RFC 4034 specifies the presentation format of the DNSKEY public key, RRSIG signature, and DS digest fields (base64, base64, and hexadecimal). With this change, when fields are represented as such, the package will use the corresponding encoding.
This commit is contained in:
parent
52e7f4aa40
commit
530d20bb93
21
index.js
21
index.js
@ -894,10 +894,7 @@ rdnskey.encode = function (key, buf, offset) {
|
|||||||
if (!offset) offset = 0
|
if (!offset) offset = 0
|
||||||
const oldOffset = offset
|
const oldOffset = offset
|
||||||
|
|
||||||
const keydata = key.key
|
const keydata = Buffer.from(key.key, 'base64')
|
||||||
if (!Buffer.isBuffer(keydata)) {
|
|
||||||
throw new Error('Key must be a Buffer')
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += 2 // Leave space for length
|
offset += 2 // Leave space for length
|
||||||
buf.writeUInt16BE(key.flags, offset)
|
buf.writeUInt16BE(key.flags, offset)
|
||||||
@ -940,7 +937,7 @@ rdnskey.decode = function (buf, offset) {
|
|||||||
rdnskey.decode.bytes = 0
|
rdnskey.decode.bytes = 0
|
||||||
|
|
||||||
rdnskey.encodingLength = function (key) {
|
rdnskey.encodingLength = function (key) {
|
||||||
return 6 + Buffer.byteLength(key.key)
|
return 6 + Buffer.byteLength(key.key, 'base64')
|
||||||
}
|
}
|
||||||
|
|
||||||
const rrrsig = exports.rrsig = {}
|
const rrrsig = exports.rrsig = {}
|
||||||
@ -950,10 +947,7 @@ rrrsig.encode = function (sig, buf, offset) {
|
|||||||
if (!offset) offset = 0
|
if (!offset) offset = 0
|
||||||
const oldOffset = offset
|
const oldOffset = offset
|
||||||
|
|
||||||
const signature = sig.signature
|
const signature = Buffer.from(sig.signature, 'base64')
|
||||||
if (!Buffer.isBuffer(signature)) {
|
|
||||||
throw new Error('Signature must be a Buffer')
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += 2 // Leave space for length
|
offset += 2 // Leave space for length
|
||||||
buf.writeUInt16BE(types.toType(sig.typeCovered), offset)
|
buf.writeUInt16BE(types.toType(sig.typeCovered), offset)
|
||||||
@ -1016,7 +1010,7 @@ rrrsig.decode.bytes = 0
|
|||||||
rrrsig.encodingLength = function (sig) {
|
rrrsig.encodingLength = function (sig) {
|
||||||
return 20 +
|
return 20 +
|
||||||
name.encodingLength(sig.signersName) +
|
name.encodingLength(sig.signersName) +
|
||||||
Buffer.byteLength(sig.signature)
|
Buffer.byteLength(sig.signature, 'base64')
|
||||||
}
|
}
|
||||||
|
|
||||||
const rrp = exports.rp = {}
|
const rrp = exports.rp = {}
|
||||||
@ -1267,10 +1261,7 @@ rds.encode = function (digest, buf, offset) {
|
|||||||
if (!offset) offset = 0
|
if (!offset) offset = 0
|
||||||
const oldOffset = offset
|
const oldOffset = offset
|
||||||
|
|
||||||
const digestdata = digest.digest
|
const digestdata = Buffer.from(digest.digest, 'hex')
|
||||||
if (!Buffer.isBuffer(digestdata)) {
|
|
||||||
throw new Error('Digest must be a Buffer')
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += 2 // Leave space for length
|
offset += 2 // Leave space for length
|
||||||
buf.writeUInt16BE(digest.keyTag, offset)
|
buf.writeUInt16BE(digest.keyTag, offset)
|
||||||
@ -1311,7 +1302,7 @@ rds.decode = function (buf, offset) {
|
|||||||
rds.decode.bytes = 0
|
rds.decode.bytes = 0
|
||||||
|
|
||||||
rds.encodingLength = function (digest) {
|
rds.encodingLength = function (digest) {
|
||||||
return 6 + Buffer.byteLength(digest.digest)
|
return 6 + Buffer.byteLength(digest.digest, 'hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
const rsshfp = exports.sshfp = {}
|
const rsshfp = exports.sshfp = {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user