werift 0.25.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/src/binaryData.d.ts +116 -0
- package/lib/common/src/binaryData.js +421 -0
- package/lib/common/src/binaryData.js.map +1 -0
- package/lib/common/src/index.d.ts +1 -0
- package/lib/common/src/index.js +24 -0
- package/lib/common/src/index.js.map +1 -1
- package/lib/dtls/src/cipher/prf.d.ts +2 -2
- package/lib/dtls/src/cipher/prf.js +2 -2
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/context/cipher.js +4 -3
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/handshake/binary.d.ts +12 -8
- package/lib/dtls/src/handshake/binary.js +3 -2
- package/lib/dtls/src/handshake/binary.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/ellipticCurves.d.ts +4 -3
- package/lib/dtls/src/handshake/extensions/ellipticCurves.js +7 -6
- package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.d.ts +4 -3
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +6 -6
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/signature.d.ts +7 -3
- package/lib/dtls/src/handshake/extensions/signature.js +6 -6
- package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +4 -3
- package/lib/dtls/src/handshake/extensions/useSrtp.js +6 -6
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.d.ts +4 -3
- package/lib/dtls/src/handshake/message/alert.js +6 -6
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.d.ts +3 -2
- package/lib/dtls/src/handshake/message/certificate.js +5 -5
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.d.ts +3 -2
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +5 -5
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +4 -3
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +6 -6
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.d.ts +14 -10
- package/lib/dtls/src/handshake/message/client/hello.js +9 -9
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.d.ts +3 -2
- package/lib/dtls/src/handshake/message/client/keyExchange.js +5 -5
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +8 -4
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -7
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.d.ts +9 -8
- package/lib/dtls/src/handshake/message/server/hello.js +11 -11
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js +4 -4
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.d.ts +5 -4
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -5
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +10 -9
- package/lib/dtls/src/handshake/message/server/keyExchange.js +11 -10
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +5 -4
- package/lib/dtls/src/handshake/random.js +6 -6
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +8 -7
- package/lib/dtls/src/record/message/fragment.js +10 -10
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.d.ts +8 -7
- package/lib/dtls/src/record/message/header.js +8 -8
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.d.ts +1 -1
- package/lib/dtls/src/socket.d.ts +4 -4
- package/lib/dtls/src/socket.js +6 -6
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/util/binary.d.ts +2 -1
- package/lib/dtls/src/util/binary.js +3 -2
- package/lib/dtls/src/util/binary.js.map +1 -1
- package/lib/index.mjs +517 -210
- package/lib/nonstandard/index.mjs +500 -194
- package/lib/polyfill/dom.mjs +538 -232
- package/lib/polyfill/index.mjs +538 -232
- package/package.json +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prf.js","sourceRoot":"","sources":["../../../../../dtls/src/cipher/prf.ts"],"names":[],"mappings":";;;;;AAOA,gDAaC;AAED,oBAIC;AAED,4BAmBC;AAED,0CAWC;AAED,0DAWC;AAED,oDAYC;AAED,oBAEC;AAED,sCAYC;AAED,kDAEC;AAED,kDAEC;AAED,8CAiCC;AApJD,mCAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"prf.js","sourceRoot":"","sources":["../../../../../dtls/src/cipher/prf.ts"],"names":[],"mappings":";;;;;AAOA,gDAaC;AAED,oBAIC;AAED,4BAmBC;AAED,0CAWC;AAED,0DAWC;AAED,oDAYC;AAED,oBAEC;AAED,sCAYC;AAED,kDAEC;AAED,kDAEC;AAED,8CAiCC;AApJD,mCAAgD;AAChD,0DAA6B;AAE7B,8CAA+C;AAC/C,mCAAyE;AACzE,6BAA2C;AAE3C,SAAgB,kBAAkB,CAChC,SAAiB,EACjB,UAAkB,EAClB,KAA2B;IAE3B,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,2BAAmB,CAAC,YA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GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAExD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEjD,mBAAmB,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACzC,mBAAmB,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEzC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import { createHash, createHmac } from \"crypto\";\nimport nacl from \"tweetnacl\";\n\nimport { binaryData } from \"../imports/common\";\nimport { NamedCurveAlgorithm, type NamedCurveAlgorithms } from \"./const\";\nimport { p256PreMasterSecret } from \"./ec\";\n\nexport function prfPreMasterSecret(\n publicKey: Buffer,\n privateKey: Buffer,\n curve: NamedCurveAlgorithms,\n) {\n switch (curve) {\n case NamedCurveAlgorithm.secp256r1_23:\n return p256PreMasterSecret({ publicKey, privateKey });\n case NamedCurveAlgorithm.x25519_29:\n return Buffer.from(nacl.scalarMult(privateKey, publicKey));\n default:\n throw new Error();\n }\n}\n\nexport function hmac(algorithm: string, secret: Buffer, data: Buffer) {\n const hash = createHmac(algorithm, secret);\n hash.update(data);\n return hash.digest();\n}\n\nexport function prfPHash(\n secret: Buffer,\n seed: Buffer,\n requestedLegth: number,\n algorithm = \"sha256\",\n) {\n const totalLength = requestedLegth;\n const bufs: Buffer[] = [];\n let Ai = seed; // A0\n\n do {\n Ai = hmac(algorithm, secret, Ai); // A(i) = HMAC(secret, A(i-1))\n const output = hmac(algorithm, secret, Buffer.concat([Ai, seed]));\n\n bufs.push(output);\n requestedLegth -= output.length; // eslint-disable-line no-param-reassign\n } while (requestedLegth > 0);\n\n return Buffer.concat(bufs, totalLength);\n}\n\nexport function prfMasterSecret(\n preMasterSecret: Buffer,\n clientRandom: Buffer,\n serverRandom: Buffer,\n) {\n const seed = Buffer.concat([\n Buffer.from(\"master secret\"),\n clientRandom,\n serverRandom,\n ]);\n return prfPHash(preMasterSecret, seed, 48);\n}\n\nexport function prfExtendedMasterSecret(\n preMasterSecret: Buffer,\n handshakes: Buffer,\n) {\n const sessionHash = hash(\"sha256\", handshakes);\n const label = \"extended master secret\";\n return prfPHash(\n preMasterSecret,\n Buffer.concat([Buffer.from(label), sessionHash]),\n 48,\n );\n}\n\nexport function exportKeyingMaterial(\n label: string,\n length: number,\n masterSecret: Buffer,\n localRandom: Buffer,\n remoteRandom: Buffer,\n isClient: boolean,\n) {\n const clientRandom = isClient ? localRandom : remoteRandom;\n const serverRandom = isClient ? remoteRandom : localRandom;\n const seed = Buffer.concat([Buffer.from(label), clientRandom, serverRandom]);\n return prfPHash(masterSecret, seed, length);\n}\n\nexport function hash(algorithm: string, data: Buffer) {\n return createHash(algorithm).update(data).digest();\n}\n\nexport function prfVerifyData(\n masterSecret: Buffer,\n handshakes: Buffer,\n label: string,\n size = 12,\n) {\n const bytes = hash(\"sha256\", handshakes);\n return prfPHash(\n masterSecret,\n Buffer.concat([Buffer.from(label), bytes]),\n size,\n );\n}\n\nexport function prfVerifyDataClient(masterSecret: Buffer, handshakes: Buffer) {\n return prfVerifyData(masterSecret, handshakes, \"client finished\");\n}\n\nexport function prfVerifyDataServer(masterSecret: Buffer, handshakes: Buffer) {\n return prfVerifyData(masterSecret, handshakes, \"server finished\");\n}\n\nexport function prfEncryptionKeys(\n masterSecret: Buffer,\n clientRandom: Buffer,\n serverRandom: Buffer,\n prfKeyLen: number,\n prfIvLen: number,\n prfNonceLen: number,\n algorithm = \"sha256\",\n) {\n const size = prfKeyLen * 2 + prfIvLen * 2;\n const secret = masterSecret;\n const seed = Buffer.concat([serverRandom, clientRandom]);\n const keyBlock = prfPHash(\n secret,\n Buffer.concat([Buffer.from(\"key expansion\"), seed]),\n size,\n algorithm,\n );\n const stream = new binaryData.BinaryReader(keyBlock);\n\n const clientWriteKey = stream.readBuffer(prfKeyLen);\n const serverWriteKey = stream.readBuffer(prfKeyLen);\n\n const clientNonceImplicit = stream.readBuffer(prfIvLen);\n const serverNonceImplicit = stream.readBuffer(prfIvLen);\n\n const clientNonce = Buffer.alloc(prfNonceLen, 0);\n const serverNonce = Buffer.alloc(prfNonceLen, 0);\n\n clientNonceImplicit.copy(clientNonce, 0);\n serverNonceImplicit.copy(serverNonce, 0);\n\n return { clientWriteKey, serverWriteKey, clientNonce, serverNonce };\n}\n"]}
|
|
@@ -38,10 +38,11 @@ exports.CipherContext = void 0;
|
|
|
38
38
|
const crypto_1 = require("crypto");
|
|
39
39
|
const x509_1 = require("@fidm/x509");
|
|
40
40
|
const x509 = __importStar(require("@peculiar/x509"));
|
|
41
|
-
const
|
|
41
|
+
const common_1 = require("../imports/common");
|
|
42
42
|
const const_1 = require("../cipher/const");
|
|
43
43
|
const prf_1 = require("../cipher/prf");
|
|
44
44
|
const abstract_1 = require("../cipher/suites/abstract");
|
|
45
|
+
const { encode, types } = common_1.binaryData;
|
|
45
46
|
const crypto = crypto_1.webcrypto;
|
|
46
47
|
x509.cryptoProvider.set(crypto);
|
|
47
48
|
class CipherContext {
|
|
@@ -195,11 +196,11 @@ class CipherContext {
|
|
|
195
196
|
this.signatureHashAlgorithm = signatureHash;
|
|
196
197
|
}
|
|
197
198
|
valueKeySignature(clientRandom, serverRandom, publicKey, namedCurve) {
|
|
198
|
-
const serverParams =
|
|
199
|
+
const serverParams = encode({
|
|
199
200
|
type: const_1.CurveType.named_curve_3,
|
|
200
201
|
curve: namedCurve,
|
|
201
202
|
len: publicKey.length,
|
|
202
|
-
}, { type:
|
|
203
|
+
}, { type: types.uint8, curve: types.uint16be, len: types.uint8 });
|
|
203
204
|
return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey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C;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CACrC,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,UAAiB,CAAC,EAC9D,aAAa,CACd,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAC5C,CAAC;EArEwC,CAqEvC","sourcesContent":["import { createSign, randomBytes, webcrypto } from \"crypto\";\nimport { Certificate, PrivateKey } from \"@fidm/x509\";\nimport * as x509 from \"@peculiar/x509\";\nimport { encode, types } from \"@shinyoshiaki/binary-data\";\n\nimport {\n type CipherSuites,\n CurveType,\n HashAlgorithm,\n NamedCurveAlgorithm,\n type NamedCurveAlgorithms,\n SignatureAlgorithm,\n type SignatureHash,\n} from \"../cipher/const\";\nimport type { NamedCurveKeyPair } from \"../cipher/namedCurve\";\nimport { prfVerifyDataClient, prfVerifyDataServer } from \"../cipher/prf\";\nimport { SessionType, type SessionTypes } from \"../cipher/suites/abstract\";\nimport type AEADCipher from \"../cipher/suites/aead\";\nimport type { DtlsRandom } from \"../handshake/random\";\nimport type { DtlsPlaintext } from \"../record/message/plaintext\";\n\nconst crypto = webcrypto;\nx509.cryptoProvider.set(crypto as any);\n\nexport class CipherContext {\n localRandom!: DtlsRandom;\n remoteRandom!: DtlsRandom;\n cipherSuite!: CipherSuites;\n remoteCertificate?: Buffer;\n remoteKeyPair!: Partial<NamedCurveKeyPair>;\n localKeyPair!: NamedCurveKeyPair;\n masterSecret!: Buffer;\n cipher!: AEADCipher;\n namedCurve!: NamedCurveAlgorithms;\n signatureHashAlgorithm?: SignatureHash;\n localCert!: Buffer;\n localPrivateKey!: PrivateKey;\n\n constructor(\n public sessionType: SessionTypes,\n public certPem?: string,\n public keyPem?: string,\n signatureHashAlgorithm?: SignatureHash,\n ) {\n if (certPem && keyPem && signatureHashAlgorithm) {\n this.parseX509(certPem, keyPem, signatureHashAlgorithm);\n }\n }\n\n /**\n *\n * @param signatureHash\n * @param namedCurveAlgorithm necessary when use ecdsa\n */\n static createSelfSignedCertificateWithKey = async (\n signatureHash: SignatureHash,\n namedCurveAlgorithm?: NamedCurveAlgorithms,\n ) => {\n const signatureAlgorithmName = (() => {\n switch (signatureHash.signature) {\n case SignatureAlgorithm.rsa_1:\n return \"RSASSA-PKCS1-v1_5\";\n case SignatureAlgorithm.ecdsa_3:\n return \"ECDSA\";\n }\n })();\n const hash = (() => {\n switch (signatureHash.hash) {\n case HashAlgorithm.sha256_4:\n return \"SHA-256\";\n }\n })();\n const namedCurve = (() => {\n switch (namedCurveAlgorithm) {\n case NamedCurveAlgorithm.secp256r1_23:\n return \"P-256\";\n case NamedCurveAlgorithm.x25519_29:\n // todo fix (X25519 not supported with ECDSA)\n if (signatureAlgorithmName === \"ECDSA\") {\n return \"P-256\";\n }\n return \"X25519\";\n default: {\n if (signatureAlgorithmName === \"ECDSA\") return \"P-256\";\n if (signatureAlgorithmName === \"RSASSA-PKCS1-v1_5\") return \"X25519\";\n }\n }\n })();\n const alg = (() => {\n switch (signatureAlgorithmName) {\n case \"ECDSA\":\n return { name: signatureAlgorithmName, hash, namedCurve };\n case \"RSASSA-PKCS1-v1_5\":\n return {\n name: signatureAlgorithmName,\n hash,\n publicExponent: new Uint8Array([1, 0, 1]),\n modulusLength: 2048,\n };\n }\n })();\n\n const keys = (await crypto.subtle.generateKey(alg, true, [\n \"sign\",\n \"verify\",\n ])) as webcrypto.CryptoKeyPair;\n\n const cert = await x509.X509CertificateGenerator.createSelfSigned({\n serialNumber: randomBytes(8).toString(\"hex\"),\n name: \"C=AU, ST=Some-State, O=Internet Widgits Pty Ltd\",\n notBefore: new Date(),\n notAfter: new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000),\n signingAlgorithm: alg,\n keys,\n });\n\n const certPem = cert.toString(\"pem\");\n const keyPem = x509.PemConverter.encode(\n await crypto.subtle.exportKey(\"pkcs8\", keys.privateKey as any),\n \"private key\",\n );\n\n return { certPem, keyPem, signatureHash };\n };\n\n encryptPacket(pkt: DtlsPlaintext) {\n const header = pkt.recordLayerHeader;\n const version =\n (header.protocolVersion.major << 8) | header.protocolVersion.minor;\n const enc = this.cipher.encrypt(this.sessionType, pkt.fragment, {\n type: header.contentType,\n version,\n epoch: header.epoch,\n sequenceNumber: header.sequenceNumber,\n });\n pkt.fragment = enc;\n pkt.recordLayerHeader.contentLen = enc.length;\n return pkt;\n }\n\n decryptPacket(pkt: DtlsPlaintext) {\n const header = pkt.recordLayerHeader;\n const version =\n (header.protocolVersion.major << 8) | header.protocolVersion.minor;\n const dec = this.cipher.decrypt(this.sessionType, pkt.fragment, {\n type: header.contentType,\n version,\n epoch: header.epoch,\n sequenceNumber: header.sequenceNumber,\n });\n return dec;\n }\n\n verifyData(buf: Buffer) {\n if (this.sessionType === SessionType.CLIENT)\n return prfVerifyDataClient(this.masterSecret, buf);\n else return prfVerifyDataServer(this.masterSecret, buf);\n }\n\n signatureData(data: Buffer, hash: string) {\n const signature = createSign(hash).update(data);\n const key = this.localPrivateKey.toPEM().toString();\n const signed = signature.sign(key);\n return signed;\n }\n\n generateKeySignature(hashAlgorithm: string) {\n const clientRandom =\n this.sessionType === SessionType.CLIENT\n ? this.localRandom\n : this.remoteRandom;\n const serverRandom =\n this.sessionType === SessionType.SERVER\n ? this.localRandom\n : this.remoteRandom;\n\n const sig = this.valueKeySignature(\n clientRandom.serialize(),\n serverRandom.serialize(),\n this.localKeyPair.publicKey,\n this.namedCurve,\n );\n\n const enc = this.localPrivateKey.sign(sig, hashAlgorithm);\n return enc;\n }\n\n parseX509(certPem: string, keyPem: string, signatureHash: SignatureHash) {\n const cert = Certificate.fromPEM(Buffer.from(certPem));\n const sec = PrivateKey.fromPEM(Buffer.from(keyPem));\n this.localCert = cert.raw;\n this.localPrivateKey = sec;\n this.signatureHashAlgorithm = signatureHash;\n }\n\n private valueKeySignature(\n clientRandom: Buffer,\n serverRandom: Buffer,\n publicKey: Buffer,\n namedCurve: number,\n ) {\n const serverParams = Buffer.from(\n encode(\n {\n type: CurveType.named_curve_3,\n curve: namedCurve,\n len: publicKey.length,\n },\n { type: types.uint8, curve: types.uint16be, len: types.uint8 },\n ).slice(),\n );\n return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cipher.js","sourceRoot":"","sources":["../../../../../dtls/src/context/cipher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA4D;AAC5D,qCAAqD;AACrD,qDAAuC;AACvC,8CAA+C;AAE/C,2CAQyB;AAEzB,uCAAyE;AACzE,wDAA2E;AAK3E,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAU,CAAC;AAErC,MAAM,MAAM,GAAG,kBAAS,CAAC;AACzB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAa,CAAC,CAAC;AAEvC,MAAa,aAAa;IAcxB,YACS,WAAyB,EACzB,OAAgB,EAChB,MAAe,EACtB,sBAAsC;QAHtC;;;;mBAAO,WAAW;WAAc;QAChC;;;;mBAAO,OAAO;WAAS;QACvB;;;;mBAAO,MAAM;WAAS;QAhBxB;;;;;WAAyB;QACzB;;;;;WAA0B;QAC1B;;;;;WAA2B;QAC3B;;;;;WAA2B;QAC3B;;;;;WAA2C;QAC3C;;;;;WAAiC;QACjC;;;;;WAAsB;QACtB;;;;;WAAoB;QACpB;;;;;WAAkC;QAClC;;;;;WAAuC;QACvC;;;;;WAAmB;QACnB;;;;;WAA6B;QAQ3B,IAAI,OAAO,IAAI,MAAM,IAAI,sBAAsB,EAAE,CAAC;YAChD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IA8ED,aAAa,CAAC,GAAkB;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC;QACrC,MAAM,OAAO,GACX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,GAAG,IAAI,CAAC;YAC/D,gBAAgB,EAAE,GAAG;YACrB,IAAI;SACL,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CACrC,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,UAAiB,CAAC,EAC9D,aAAa,CACd,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAC5C,CAAC;EArEwC,CAqEvC","sourcesContent":["import { createSign, randomBytes, webcrypto } from \"crypto\";\nimport { Certificate, PrivateKey } from \"@fidm/x509\";\nimport * as x509 from \"@peculiar/x509\";\nimport { binaryData } from \"../imports/common\";\n\nimport {\n type CipherSuites,\n CurveType,\n HashAlgorithm,\n NamedCurveAlgorithm,\n type NamedCurveAlgorithms,\n SignatureAlgorithm,\n type SignatureHash,\n} from \"../cipher/const\";\nimport type { NamedCurveKeyPair } from \"../cipher/namedCurve\";\nimport { prfVerifyDataClient, prfVerifyDataServer } from \"../cipher/prf\";\nimport { SessionType, type SessionTypes } from \"../cipher/suites/abstract\";\nimport type AEADCipher from \"../cipher/suites/aead\";\nimport type { DtlsRandom } from \"../handshake/random\";\nimport type { DtlsPlaintext } from \"../record/message/plaintext\";\n\nconst { encode, types } = binaryData;\n\nconst crypto = webcrypto;\nx509.cryptoProvider.set(crypto as any);\n\nexport class CipherContext {\n localRandom!: DtlsRandom;\n remoteRandom!: DtlsRandom;\n cipherSuite!: CipherSuites;\n remoteCertificate?: Buffer;\n remoteKeyPair!: Partial<NamedCurveKeyPair>;\n localKeyPair!: NamedCurveKeyPair;\n masterSecret!: Buffer;\n cipher!: AEADCipher;\n namedCurve!: NamedCurveAlgorithms;\n signatureHashAlgorithm?: SignatureHash;\n localCert!: Buffer;\n localPrivateKey!: PrivateKey;\n\n constructor(\n public sessionType: SessionTypes,\n public certPem?: string,\n public keyPem?: string,\n signatureHashAlgorithm?: SignatureHash,\n ) {\n if (certPem && keyPem && signatureHashAlgorithm) {\n this.parseX509(certPem, keyPem, signatureHashAlgorithm);\n }\n }\n\n /**\n *\n * @param signatureHash\n * @param namedCurveAlgorithm necessary when use ecdsa\n */\n static createSelfSignedCertificateWithKey = async (\n signatureHash: SignatureHash,\n namedCurveAlgorithm?: NamedCurveAlgorithms,\n ) => {\n const signatureAlgorithmName = (() => {\n switch (signatureHash.signature) {\n case SignatureAlgorithm.rsa_1:\n return \"RSASSA-PKCS1-v1_5\";\n case SignatureAlgorithm.ecdsa_3:\n return \"ECDSA\";\n }\n })();\n const hash = (() => {\n switch (signatureHash.hash) {\n case HashAlgorithm.sha256_4:\n return \"SHA-256\";\n }\n })();\n const namedCurve = (() => {\n switch (namedCurveAlgorithm) {\n case NamedCurveAlgorithm.secp256r1_23:\n return \"P-256\";\n case NamedCurveAlgorithm.x25519_29:\n // todo fix (X25519 not supported with ECDSA)\n if (signatureAlgorithmName === \"ECDSA\") {\n return \"P-256\";\n }\n return \"X25519\";\n default: {\n if (signatureAlgorithmName === \"ECDSA\") return \"P-256\";\n if (signatureAlgorithmName === \"RSASSA-PKCS1-v1_5\") return \"X25519\";\n }\n }\n })();\n const alg = (() => {\n switch (signatureAlgorithmName) {\n case \"ECDSA\":\n return { name: signatureAlgorithmName, hash, namedCurve };\n case \"RSASSA-PKCS1-v1_5\":\n return {\n name: signatureAlgorithmName,\n hash,\n publicExponent: new Uint8Array([1, 0, 1]),\n modulusLength: 2048,\n };\n }\n })();\n\n const keys = (await crypto.subtle.generateKey(alg, true, [\n \"sign\",\n \"verify\",\n ])) as webcrypto.CryptoKeyPair;\n\n const cert = await x509.X509CertificateGenerator.createSelfSigned({\n serialNumber: randomBytes(8).toString(\"hex\"),\n name: \"C=AU, ST=Some-State, O=Internet Widgits Pty Ltd\",\n notBefore: new Date(),\n notAfter: new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000),\n signingAlgorithm: alg,\n keys,\n });\n\n const certPem = cert.toString(\"pem\");\n const keyPem = x509.PemConverter.encode(\n await crypto.subtle.exportKey(\"pkcs8\", keys.privateKey as any),\n \"private key\",\n );\n\n return { certPem, keyPem, signatureHash };\n };\n\n encryptPacket(pkt: DtlsPlaintext) {\n const header = pkt.recordLayerHeader;\n const version =\n (header.protocolVersion.major << 8) | header.protocolVersion.minor;\n const enc = this.cipher.encrypt(this.sessionType, pkt.fragment, {\n type: header.contentType,\n version,\n epoch: header.epoch,\n sequenceNumber: header.sequenceNumber,\n });\n pkt.fragment = enc;\n pkt.recordLayerHeader.contentLen = enc.length;\n return pkt;\n }\n\n decryptPacket(pkt: DtlsPlaintext) {\n const header = pkt.recordLayerHeader;\n const version =\n (header.protocolVersion.major << 8) | header.protocolVersion.minor;\n const dec = this.cipher.decrypt(this.sessionType, pkt.fragment, {\n type: header.contentType,\n version,\n epoch: header.epoch,\n sequenceNumber: header.sequenceNumber,\n });\n return dec;\n }\n\n verifyData(buf: Buffer) {\n if (this.sessionType === SessionType.CLIENT)\n return prfVerifyDataClient(this.masterSecret, buf);\n else return prfVerifyDataServer(this.masterSecret, buf);\n }\n\n signatureData(data: Buffer, hash: string) {\n const signature = createSign(hash).update(data);\n const key = this.localPrivateKey.toPEM().toString();\n const signed = signature.sign(key);\n return signed;\n }\n\n generateKeySignature(hashAlgorithm: string) {\n const clientRandom =\n this.sessionType === SessionType.CLIENT\n ? this.localRandom\n : this.remoteRandom;\n const serverRandom =\n this.sessionType === SessionType.SERVER\n ? this.localRandom\n : this.remoteRandom;\n\n const sig = this.valueKeySignature(\n clientRandom.serialize(),\n serverRandom.serialize(),\n this.localKeyPair.publicKey,\n this.namedCurve,\n );\n\n const enc = this.localPrivateKey.sign(sig, hashAlgorithm);\n return enc;\n }\n\n parseX509(certPem: string, keyPem: string, signatureHash: SignatureHash) {\n const cert = Certificate.fromPEM(Buffer.from(certPem));\n const sec = PrivateKey.fromPEM(Buffer.from(keyPem));\n this.localCert = cert.raw;\n this.localPrivateKey = sec;\n this.signatureHashAlgorithm = signatureHash;\n }\n\n private valueKeySignature(\n clientRandom: Buffer,\n serverRandom: Buffer,\n publicKey: Buffer,\n namedCurve: number,\n ) {\n const serverParams = encode(\n {\n type: CurveType.named_curve_3,\n curve: namedCurve,\n len: publicKey.length,\n },\n { type: types.uint8, curve: types.uint16be, len: types.uint8 },\n );\n return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey]);\n }\n}\n"]}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { binaryData } from "../imports/common";
|
|
2
|
+
export declare const ExtensionList: binaryData.DataType<{
|
|
3
|
+
type: number;
|
|
4
|
+
data: Buffer<ArrayBufferLike>;
|
|
5
|
+
}[]>;
|
|
6
|
+
export declare const ASN11Cert: binaryData.DataType<Buffer<ArrayBufferLike>>;
|
|
7
|
+
export declare const ClientCertificateType: binaryData.NumberType;
|
|
8
|
+
export declare const DistinguishedName: binaryData.DataType<string>;
|
|
5
9
|
export declare const SignatureHashAlgorithm: {
|
|
6
|
-
hash:
|
|
7
|
-
signature:
|
|
10
|
+
hash: binaryData.NumberType;
|
|
11
|
+
signature: binaryData.NumberType;
|
|
8
12
|
};
|
|
9
13
|
export declare const ProtocolVersion: {
|
|
10
|
-
major:
|
|
11
|
-
minor:
|
|
14
|
+
major: binaryData.NumberType;
|
|
15
|
+
minor: binaryData.NumberType;
|
|
12
16
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProtocolVersion = exports.SignatureHashAlgorithm = exports.DistinguishedName = exports.ClientCertificateType = exports.ASN11Cert = exports.ExtensionList = void 0;
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
4
|
+
const common_1 = require("../imports/common");
|
|
5
|
+
const { types } = common_1.binaryData;
|
|
6
|
+
const { uint16be, uint24be, buffer, array, uint8, string } = types;
|
|
6
7
|
// export const Random = {
|
|
7
8
|
// gmt_unix_time: uint32be,
|
|
8
9
|
// random_bytes: buffer(28),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../../../dtls/src/handshake/binary.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../../../dtls/src/handshake/binary.ts"],"names":[],"mappings":";;;AAAA,8CAA+C;AAE/C,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAU,CAAC;AAE7B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;AAEnE,0BAA0B;AAC1B,6BAA6B;AAC7B,8BAA8B;AAC9B,KAAK;AAEL,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC;CACvB,CAAC;AAEW,QAAA,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAEpD,QAAA,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE7B,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAC9B,QAAA,iBAAiB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAErC,QAAA,sBAAsB,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAE3D,QAAA,eAAe,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { binaryData } from \"../imports/common\";\n\nconst { types } = binaryData;\n\nconst { uint16be, uint24be, buffer, array, uint8, string } = types;\n\n// export const Random = {\n// gmt_unix_time: uint32be,\n// random_bytes: buffer(28),\n// };\n\nconst Extension = {\n type: uint16be,\n data: buffer(uint16be),\n};\n\nexport const ExtensionList = array(Extension, uint16be, \"bytes\");\n\nexport const ASN11Cert = buffer(uint24be);\n\nexport const ClientCertificateType = uint8;\nexport const DistinguishedName = string(uint16be);\n\nexport const SignatureHashAlgorithm = { hash: uint8, signature: uint8 };\n\nexport const ProtocolVersion = { major: uint8, minor: uint8 };\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { binaryData } from "../../imports/common";
|
|
1
2
|
import type { Extension } from "../../typings/domain";
|
|
2
3
|
export declare class EllipticCurves {
|
|
3
4
|
static type: number;
|
|
4
5
|
static readonly spec: {
|
|
5
|
-
type:
|
|
6
|
-
data:
|
|
6
|
+
type: binaryData.NumberType;
|
|
7
|
+
data: binaryData.DataType<number[]>;
|
|
7
8
|
};
|
|
8
9
|
type: number;
|
|
9
10
|
data: number[];
|
|
@@ -11,6 +12,6 @@ export declare class EllipticCurves {
|
|
|
11
12
|
static createEmpty(): EllipticCurves;
|
|
12
13
|
static fromData(buf: Buffer): EllipticCurves;
|
|
13
14
|
static deSerialize(buf: Buffer): EllipticCurves;
|
|
14
|
-
serialize(): Buffer<
|
|
15
|
+
serialize(): Buffer<ArrayBufferLike>;
|
|
15
16
|
get extension(): Extension;
|
|
16
17
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EllipticCurves = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../imports/common");
|
|
5
|
+
const { decode, encode, types } = common_1.binaryData;
|
|
5
6
|
// rfc4492
|
|
6
7
|
class EllipticCurves {
|
|
7
8
|
constructor(props = {}) {
|
|
@@ -25,14 +26,14 @@ class EllipticCurves {
|
|
|
25
26
|
static fromData(buf) {
|
|
26
27
|
return new EllipticCurves({
|
|
27
28
|
type: EllipticCurves.type,
|
|
28
|
-
data:
|
|
29
|
+
data: decode(buf, EllipticCurves.spec.data),
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
static deSerialize(buf) {
|
|
32
|
-
return new EllipticCurves(
|
|
33
|
+
return new EllipticCurves(decode(buf, EllipticCurves.spec));
|
|
33
34
|
}
|
|
34
35
|
serialize() {
|
|
35
|
-
return
|
|
36
|
+
return encode(this, EllipticCurves.spec);
|
|
36
37
|
}
|
|
37
38
|
get extension() {
|
|
38
39
|
return {
|
|
@@ -53,8 +54,8 @@ Object.defineProperty(EllipticCurves, "spec", {
|
|
|
53
54
|
configurable: true,
|
|
54
55
|
writable: true,
|
|
55
56
|
value: {
|
|
56
|
-
type:
|
|
57
|
-
data:
|
|
57
|
+
type: types.uint16be,
|
|
58
|
+
data: types.array(types.uint16be, types.uint16be, "bytes"),
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
61
|
//# sourceMappingURL=ellipticCurves.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ellipticCurves.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/ellipticCurves.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ellipticCurves.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/ellipticCurves.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAIlD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAU,CAAC;AAE7C,UAAU;AACV,MAAa,cAAc;IAUzB,YAAY,QAAiC,EAAE;QAHxC;;;;mBAAe,cAAc,CAAC,IAAI;WAAC;QACnC;;;;mBAAiB,EAAE;WAAC;QAGzB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,GAAW;QACzB,OAAO,IAAI,cAAc,CAAC;YACxB,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,GAAW;QAC5B,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,SAAS;QACP,OAAO,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,SAAS;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SAChC,CAAC;IACJ,CAAC;;AAtCH,wCAuCC;AAtCQ;;;;WAAO,EAAE;EAAL,CAAM;AACD;;;;WAAO;QACrB,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC;KAC3D;EAHmB,CAGlB","sourcesContent":["import { binaryData } from \"../../imports/common\";\n\nimport type { Extension } from \"../../typings/domain\";\n\nconst { decode, encode, types } = binaryData;\n\n// rfc4492\nexport class EllipticCurves {\n static type = 10;\n static readonly spec = {\n type: types.uint16be,\n data: types.array(types.uint16be, types.uint16be, \"bytes\"),\n };\n\n public type: number = EllipticCurves.type;\n public data: number[] = [];\n\n constructor(props: Partial<EllipticCurves> = {}) {\n Object.assign(this, props);\n }\n\n static createEmpty() {\n return new EllipticCurves();\n }\n\n static fromData(buf: Buffer) {\n return new EllipticCurves({\n type: EllipticCurves.type,\n data: decode(buf, EllipticCurves.spec.data),\n });\n }\n\n static deSerialize(buf: Buffer) {\n return new EllipticCurves(decode(buf, EllipticCurves.spec));\n }\n\n serialize() {\n return encode(this, EllipticCurves.spec);\n }\n\n get extension(): Extension {\n return {\n type: this.type,\n data: this.serialize().slice(2),\n };\n }\n}\n"]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { binaryData } from "../../imports/common";
|
|
1
2
|
export declare class RenegotiationIndication {
|
|
2
3
|
static type: number;
|
|
3
4
|
static readonly spec: {
|
|
4
|
-
type:
|
|
5
|
-
data:
|
|
5
|
+
type: binaryData.NumberType;
|
|
6
|
+
data: binaryData.NumberType;
|
|
6
7
|
};
|
|
7
8
|
type: number;
|
|
8
9
|
data: number;
|
|
9
10
|
constructor(props?: Partial<RenegotiationIndication>);
|
|
10
11
|
static createEmpty(): RenegotiationIndication;
|
|
11
12
|
static deSerialize(buf: Buffer): RenegotiationIndication;
|
|
12
|
-
serialize(): Buffer<
|
|
13
|
+
serialize(): Buffer<ArrayBufferLike>;
|
|
13
14
|
get extension(): {
|
|
14
15
|
type: number;
|
|
15
16
|
data: Buffer<ArrayBuffer>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RenegotiationIndication = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../imports/common");
|
|
5
|
+
const { decode, encode, types } = common_1.binaryData;
|
|
5
6
|
class RenegotiationIndication {
|
|
6
7
|
constructor(props = {}) {
|
|
7
8
|
Object.defineProperty(this, "type", {
|
|
@@ -23,11 +24,10 @@ class RenegotiationIndication {
|
|
|
23
24
|
return v;
|
|
24
25
|
}
|
|
25
26
|
static deSerialize(buf) {
|
|
26
|
-
return new RenegotiationIndication(
|
|
27
|
+
return new RenegotiationIndication(decode(buf, RenegotiationIndication.spec));
|
|
27
28
|
}
|
|
28
29
|
serialize() {
|
|
29
|
-
|
|
30
|
-
return Buffer.from(res);
|
|
30
|
+
return encode(this, RenegotiationIndication.spec);
|
|
31
31
|
}
|
|
32
32
|
get extension() {
|
|
33
33
|
return {
|
|
@@ -48,8 +48,8 @@ Object.defineProperty(RenegotiationIndication, "spec", {
|
|
|
48
48
|
configurable: true,
|
|
49
49
|
writable: true,
|
|
50
50
|
value: {
|
|
51
|
-
type:
|
|
52
|
-
data:
|
|
51
|
+
type: types.uint16be,
|
|
52
|
+
data: types.uint8,
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
//# sourceMappingURL=renegotiationIndication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renegotiationIndication.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/renegotiationIndication.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"renegotiationIndication.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/renegotiationIndication.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAElD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAU,CAAC;AAE7C,MAAa,uBAAuB;IAUlC,YAAY,QAA0C,EAAE;QAHjD;;;;mBAAe,uBAAuB,CAAC,IAAI;WAAC;QAC5C;;;;mBAAe,CAAC;WAAC;QAGtB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,MAAM,CAAC,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACxC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,GAAW;QAC5B,OAAO,IAAI,uBAAuB,CAChC,MAAM,CAAC,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAC1C,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,SAAS;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SAChC,CAAC;IACJ,CAAC;;AAlCH,0DAmCC;AAlCQ;;;;WAAO,KAAK;EAAR,CAAS;AACJ;;;;WAAO;QACrB,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,IAAI,EAAE,KAAK,CAAC,KAAK;KAClB;EAHmB,CAGlB","sourcesContent":["import { binaryData } from \"../../imports/common\";\n\nconst { decode, encode, types } = binaryData;\n\nexport class RenegotiationIndication {\n static type = 65281;\n static readonly spec = {\n type: types.uint16be,\n data: types.uint8,\n };\n\n public type: number = RenegotiationIndication.type;\n public data: number = 0;\n\n constructor(props: Partial<RenegotiationIndication> = {}) {\n Object.assign(this, props);\n }\n\n static createEmpty() {\n const v = new RenegotiationIndication();\n return v;\n }\n\n static deSerialize(buf: Buffer) {\n return new RenegotiationIndication(\n decode(buf, RenegotiationIndication.spec),\n );\n }\n\n serialize() {\n return encode(this, RenegotiationIndication.spec);\n }\n\n get extension() {\n return {\n type: this.type,\n data: this.serialize().slice(2),\n };\n }\n}\n"]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { binaryData } from "../../imports/common";
|
|
1
2
|
import type { HashAlgorithms, SignatureAlgorithms } from "../../cipher/const";
|
|
2
3
|
export declare class Signature {
|
|
3
4
|
static type: number;
|
|
4
5
|
static readonly spec: {
|
|
5
|
-
type:
|
|
6
|
-
data:
|
|
6
|
+
type: binaryData.NumberType;
|
|
7
|
+
data: binaryData.DataType<{
|
|
8
|
+
hash: number;
|
|
9
|
+
signature: number;
|
|
10
|
+
}[]>;
|
|
7
11
|
};
|
|
8
12
|
type: number;
|
|
9
13
|
data: {
|
|
@@ -13,7 +17,7 @@ export declare class Signature {
|
|
|
13
17
|
constructor(props?: Partial<Signature>);
|
|
14
18
|
static createEmpty(): Signature;
|
|
15
19
|
static deSerialize(buf: Buffer): Signature;
|
|
16
|
-
serialize(): Buffer<
|
|
20
|
+
serialize(): Buffer<ArrayBufferLike>;
|
|
17
21
|
static fromData(buf: Buffer): Signature;
|
|
18
22
|
get extension(): {
|
|
19
23
|
type: number;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Signature = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../imports/common");
|
|
5
|
+
const { decode, encode, types } = common_1.binaryData;
|
|
5
6
|
class Signature {
|
|
6
7
|
constructor(props = {}) {
|
|
7
8
|
Object.defineProperty(this, "type", {
|
|
@@ -23,11 +24,10 @@ class Signature {
|
|
|
23
24
|
return v;
|
|
24
25
|
}
|
|
25
26
|
static deSerialize(buf) {
|
|
26
|
-
return new Signature(
|
|
27
|
+
return new Signature(decode(buf, Signature.spec));
|
|
27
28
|
}
|
|
28
29
|
serialize() {
|
|
29
|
-
|
|
30
|
-
return Buffer.from(res);
|
|
30
|
+
return encode(this, Signature.spec);
|
|
31
31
|
}
|
|
32
32
|
static fromData(buf) {
|
|
33
33
|
const type = Buffer.alloc(2);
|
|
@@ -53,8 +53,8 @@ Object.defineProperty(Signature, "spec", {
|
|
|
53
53
|
configurable: true,
|
|
54
54
|
writable: true,
|
|
55
55
|
value: {
|
|
56
|
-
type:
|
|
57
|
-
data:
|
|
56
|
+
type: types.uint16be,
|
|
57
|
+
data: types.array({ hash: types.uint8, signature: types.uint8 }, types.uint16be, "bytes"),
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
//# sourceMappingURL=signature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/signature.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/signature.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAIlD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,mBAA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ACd,OAAO,CACR;KACF;EAPmB,CAOlB","sourcesContent":["import { binaryData } from \"../../imports/common\";\n\nimport type { HashAlgorithms, SignatureAlgorithms } from \"../../cipher/const\";\n\nconst { decode, encode, types } = binaryData;\n\nexport class Signature {\n static type = 13;\n static readonly spec = {\n type: types.uint16be,\n data: types.array(\n { hash: types.uint8, signature: types.uint8 },\n types.uint16be,\n \"bytes\",\n ),\n };\n\n public type: number = Signature.type;\n public data: { hash: HashAlgorithms; signature: SignatureAlgorithms }[] = [];\n\n constructor(props: Partial<Signature> = {}) {\n Object.assign(this, props);\n }\n\n static createEmpty() {\n const v = new Signature();\n return v;\n }\n\n static deSerialize(buf: Buffer) {\n return new Signature(decode(buf, Signature.spec) as Partial<Signature>);\n }\n\n serialize() {\n return encode(this, Signature.spec);\n }\n\n static fromData(buf: Buffer) {\n const type = Buffer.alloc(2);\n type.writeUInt16BE(Signature.type);\n return Signature.deSerialize(Buffer.concat([type, buf]));\n }\n\n get extension() {\n return {\n type: this.type,\n data: this.serialize().slice(2),\n };\n }\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { binaryData } from "../../imports/common";
|
|
1
2
|
import type { Extension } from "../../typings/domain";
|
|
2
3
|
export declare class UseSRTP {
|
|
3
4
|
static type: number;
|
|
4
5
|
static readonly spec: {
|
|
5
|
-
type:
|
|
6
|
-
data:
|
|
6
|
+
type: binaryData.NumberType;
|
|
7
|
+
data: binaryData.DataType<Buffer<ArrayBufferLike>>;
|
|
7
8
|
};
|
|
8
9
|
type: number;
|
|
9
10
|
data: Buffer;
|
|
@@ -12,7 +13,7 @@ export declare class UseSRTP {
|
|
|
12
13
|
constructor(props?: Partial<UseSRTP>);
|
|
13
14
|
static create(profiles: number[], mki: Buffer): UseSRTP;
|
|
14
15
|
static deSerialize(buf: Buffer): UseSRTP;
|
|
15
|
-
serialize(): Buffer<
|
|
16
|
+
serialize(): Buffer<ArrayBufferLike>;
|
|
16
17
|
static fromData(buf: Buffer): UseSRTP;
|
|
17
18
|
get extension(): Extension;
|
|
18
19
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UseSRTP = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../imports/common");
|
|
5
|
+
const { decode, encode, types } = common_1.binaryData;
|
|
5
6
|
class UseSRTP {
|
|
6
7
|
constructor(props = {}) {
|
|
7
8
|
Object.defineProperty(this, "type", {
|
|
@@ -38,7 +39,7 @@ class UseSRTP {
|
|
|
38
39
|
return v;
|
|
39
40
|
}
|
|
40
41
|
static deSerialize(buf) {
|
|
41
|
-
const useSrtp = new UseSRTP(
|
|
42
|
+
const useSrtp = new UseSRTP(decode(buf, UseSRTP.spec));
|
|
42
43
|
const profileLength = useSrtp.data.readUInt16BE();
|
|
43
44
|
const profiles = new Array(profileLength / 2);
|
|
44
45
|
for (let i = 0; i < profiles.length; i++) {
|
|
@@ -61,8 +62,7 @@ class UseSRTP {
|
|
|
61
62
|
this.mki,
|
|
62
63
|
]);
|
|
63
64
|
this.data = data;
|
|
64
|
-
|
|
65
|
-
return Buffer.from(res);
|
|
65
|
+
return encode(this, UseSRTP.spec);
|
|
66
66
|
}
|
|
67
67
|
static fromData(buf) {
|
|
68
68
|
const head = Buffer.alloc(4);
|
|
@@ -89,8 +89,8 @@ Object.defineProperty(UseSRTP, "spec", {
|
|
|
89
89
|
configurable: true,
|
|
90
90
|
writable: true,
|
|
91
91
|
value: {
|
|
92
|
-
type:
|
|
93
|
-
data:
|
|
92
|
+
type: types.uint16be,
|
|
93
|
+
data: types.buffer(types.uint16be),
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
//# sourceMappingURL=useSrtp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSrtp.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/extensions/useSrtp.ts"],"names":[],"mappings":";;;AAAA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AAC,CAAC;SAChC,CAAC;IACJ,CAAC;;AAjEH,0BAkEC;AAjEQ;;;;WAAO,EAAE;EAAL,CAAM,CAAC,0BAA0B;AAC5B;;;;WAAO;QACrB,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;KACnC;EAHmB,CAGlB","sourcesContent":["import { binaryData } from \"../../imports/common\";\n\nimport type { Extension } from \"../../typings/domain\";\n\nconst { decode, encode, types } = binaryData;\n\nexport class UseSRTP {\n static type = 14; // 9. IANA Considerations\n static readonly spec = {\n type: types.uint16be,\n data: types.buffer(types.uint16be),\n };\n\n type: number = UseSRTP.type;\n data: Buffer = Buffer.from([]);\n profiles: number[] = [];\n mki: Buffer = Buffer.from([0x00]);\n\n constructor(props: Partial<UseSRTP> = {}) {\n Object.assign(this, props);\n }\n\n static create(profiles: number[], mki: Buffer) {\n const v = new UseSRTP({\n profiles,\n mki,\n });\n return v;\n }\n\n static deSerialize(buf: Buffer) {\n const useSrtp = new UseSRTP(decode(buf, UseSRTP.spec));\n const profileLength = useSrtp.data.readUInt16BE();\n\n const profiles = new Array(profileLength / 2);\n for (let i = 0; i < profiles.length; i++) {\n profiles[i] = useSrtp.data.readUInt16BE(i * 2 + 2);\n }\n useSrtp.profiles = profiles;\n useSrtp.mki = useSrtp.data.slice(profileLength + 2);\n return useSrtp;\n }\n\n serialize() {\n const profileLength = Buffer.alloc(2);\n profileLength.writeUInt16BE(this.profiles.length * 2);\n const data = Buffer.concat([\n profileLength,\n ...this.profiles.map((profile) => {\n const buf = Buffer.alloc(2);\n buf.writeUInt16BE(profile);\n return buf;\n }),\n this.mki,\n ]);\n this.data = data;\n return encode(this, UseSRTP.spec);\n }\n\n static fromData(buf: Buffer) {\n const head = Buffer.alloc(4);\n head.writeUInt16BE(UseSRTP.type);\n head.writeUInt16BE(buf.length, 2);\n return UseSRTP.deSerialize(Buffer.concat([head, buf]));\n }\n\n get extension(): Extension {\n return {\n type: this.type,\n data: this.serialize().slice(4),\n };\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { binaryData } from "../../imports/common";
|
|
1
2
|
export declare class Alert {
|
|
2
3
|
level: number;
|
|
3
4
|
description: number;
|
|
4
5
|
static readonly spec: {
|
|
5
|
-
level:
|
|
6
|
-
description:
|
|
6
|
+
level: binaryData.NumberType;
|
|
7
|
+
description: binaryData.NumberType;
|
|
7
8
|
};
|
|
8
9
|
constructor(level: number, description: number);
|
|
9
10
|
static deSerialize(buf: Buffer): Alert;
|
|
10
|
-
serialize(): Buffer<
|
|
11
|
+
serialize(): Buffer<ArrayBufferLike>;
|
|
11
12
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Alert = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../imports/common");
|
|
5
|
+
const { decode, encode, types } = common_1.binaryData;
|
|
5
6
|
class Alert {
|
|
6
7
|
constructor(level, description) {
|
|
7
8
|
Object.defineProperty(this, "level", {
|
|
@@ -20,11 +21,10 @@ class Alert {
|
|
|
20
21
|
static deSerialize(buf) {
|
|
21
22
|
return new Alert(
|
|
22
23
|
//@ts-ignore
|
|
23
|
-
...Object.values(
|
|
24
|
+
...Object.values(decode(buf, Alert.spec)));
|
|
24
25
|
}
|
|
25
26
|
serialize() {
|
|
26
|
-
|
|
27
|
-
return Buffer.from(res);
|
|
27
|
+
return encode(this, Alert.spec);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.Alert = Alert;
|
|
@@ -33,8 +33,8 @@ Object.defineProperty(Alert, "spec", {
|
|
|
33
33
|
configurable: true,
|
|
34
34
|
writable: true,
|
|
35
35
|
value: {
|
|
36
|
-
level:
|
|
37
|
-
description:
|
|
36
|
+
level: types.uint8,
|
|
37
|
+
description: types.uint8,
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
//# sourceMappingURL=alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/message/alert.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../../../../dtls/src/handshake/message/alert.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAElD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAU,CAAC;AAE7C,MAAa,KAAK;IAMhB,YACS,KAAa,EACb,WAAmB;QAD1B;;;;mBAAO,KAAK;WAAQ;QACpB;;;;mBAAO,WAAW;WAAQ;IACzB,CAAC;IAEJ,MAAM,CAAC,WAAW,CAAC,GAAW;QAC5B,OAAO,IAAI,KAAK;QACd,YAAY;QACZ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAC1C,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;;AApBH,sBAqBC;AApBiB;;;;WAAO;QACrB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,WAAW,EAAE,KAAK,CAAC,KAAK;KACzB;EAHmB,CAGlB","sourcesContent":["import { binaryData } from \"../../imports/common\";\n\nconst { decode, encode, types } = binaryData;\n\nexport class Alert {\n static readonly spec = {\n level: types.uint8,\n description: types.uint8,\n };\n\n constructor(\n public level: number,\n public description: number,\n ) {}\n\n static deSerialize(buf: Buffer) {\n return new Alert(\n //@ts-ignore\n ...Object.values(decode(buf, Alert.spec)),\n );\n }\n\n serialize() {\n return encode(this, Alert.spec);\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { binaryData } from "../../imports/common";
|
|
1
2
|
import { FragmentedHandshake } from "../../record/message/fragment";
|
|
2
3
|
import type { Handshake } from "../../typings/domain";
|
|
3
4
|
import { HandshakeType } from "../const";
|
|
@@ -6,11 +7,11 @@ export declare class Certificate implements Handshake {
|
|
|
6
7
|
msgType: HandshakeType;
|
|
7
8
|
messageSeq?: number;
|
|
8
9
|
static readonly spec: {
|
|
9
|
-
certificateList:
|
|
10
|
+
certificateList: binaryData.DataType<Buffer<ArrayBufferLike>[]>;
|
|
10
11
|
};
|
|
11
12
|
constructor(certificateList: Buffer[]);
|
|
12
13
|
static createEmpty(): Certificate;
|
|
13
14
|
static deSerialize(buf: Buffer): Certificate;
|
|
14
|
-
serialize(): Buffer<
|
|
15
|
+
serialize(): Buffer<ArrayBufferLike>;
|
|
15
16
|
toFragment(): FragmentedHandshake;
|
|
16
17
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Certificate = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../imports/common");
|
|
5
5
|
const fragment_1 = require("../../record/message/fragment");
|
|
6
6
|
const binary_1 = require("../binary");
|
|
7
7
|
const const_1 = require("../const");
|
|
8
|
+
const { decode, encode, types } = common_1.binaryData;
|
|
8
9
|
// 7.4.2. Server Certificate
|
|
9
10
|
// 7.4.6. Client Certificate
|
|
10
11
|
class Certificate {
|
|
@@ -34,11 +35,10 @@ class Certificate {
|
|
|
34
35
|
static deSerialize(buf) {
|
|
35
36
|
return new Certificate(
|
|
36
37
|
//@ts-ignore
|
|
37
|
-
...Object.values(
|
|
38
|
+
...Object.values(decode(buf, Certificate.spec)));
|
|
38
39
|
}
|
|
39
40
|
serialize() {
|
|
40
|
-
|
|
41
|
-
return Buffer.from(res);
|
|
41
|
+
return encode(this, Certificate.spec);
|
|
42
42
|
}
|
|
43
43
|
toFragment() {
|
|
44
44
|
const body = this.serialize();
|
|
@@ -51,7 +51,7 @@ Object.defineProperty(Certificate, "spec", {
|
|
|
51
51
|
configurable: true,
|
|
52
52
|
writable: true,
|
|
53
53
|
value: {
|
|
54
|
-
certificateList:
|
|
54
|
+
certificateList: types.array(binary_1.ASN11Cert, types.uint24be, "bytes"),
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
//# sourceMappingURL=certificate.js.map
|