11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst { 41cb0ef41Sopenharmony_ci certExportChallenge, 51cb0ef41Sopenharmony_ci certExportPublicKey, 61cb0ef41Sopenharmony_ci certVerifySpkac, 71cb0ef41Sopenharmony_ci} = internalBinding('crypto'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst { 101cb0ef41Sopenharmony_ci getArrayBufferOrView, 111cb0ef41Sopenharmony_ci} = require('internal/crypto/util'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// The functions contained in this file cover the SPKAC format 141cb0ef41Sopenharmony_ci// (also referred to as Netscape SPKI). A general description of 151cb0ef41Sopenharmony_ci// the format can be found at https://en.wikipedia.org/wiki/SPKAC 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_cifunction verifySpkac(spkac, encoding) { 181cb0ef41Sopenharmony_ci return certVerifySpkac( 191cb0ef41Sopenharmony_ci getArrayBufferOrView(spkac, 'spkac', encoding)); 201cb0ef41Sopenharmony_ci} 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_cifunction exportPublicKey(spkac, encoding) { 231cb0ef41Sopenharmony_ci return certExportPublicKey( 241cb0ef41Sopenharmony_ci getArrayBufferOrView(spkac, 'spkac', encoding)); 251cb0ef41Sopenharmony_ci} 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cifunction exportChallenge(spkac, encoding) { 281cb0ef41Sopenharmony_ci return certExportChallenge( 291cb0ef41Sopenharmony_ci getArrayBufferOrView(spkac, 'spkac', encoding)); 301cb0ef41Sopenharmony_ci} 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci// The legacy implementation of this exposed the Certificate 331cb0ef41Sopenharmony_ci// object and required that users create an instance before 341cb0ef41Sopenharmony_ci// calling the member methods. This API pattern has been 351cb0ef41Sopenharmony_ci// deprecated, however, as the method implementations do not 361cb0ef41Sopenharmony_ci// rely on any object state. 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci// For backwards compatibility reasons, this cannot be converted into a 391cb0ef41Sopenharmony_ci// ES6 Class. 401cb0ef41Sopenharmony_cifunction Certificate() { 411cb0ef41Sopenharmony_ci if (!(this instanceof Certificate)) 421cb0ef41Sopenharmony_ci return new Certificate(); 431cb0ef41Sopenharmony_ci} 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ciCertificate.prototype.verifySpkac = verifySpkac; 461cb0ef41Sopenharmony_ciCertificate.prototype.exportPublicKey = exportPublicKey; 471cb0ef41Sopenharmony_ciCertificate.prototype.exportChallenge = exportChallenge; 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciCertificate.exportChallenge = exportChallenge; 501cb0ef41Sopenharmony_ciCertificate.exportPublicKey = exportPublicKey; 511cb0ef41Sopenharmony_ciCertificate.verifySpkac = verifySpkac; 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_cimodule.exports = Certificate; 54