all files / core/security/digital-signature/x509/ x509-algorithm.js

25% Statements 10/40
0% Branches 0/15
28.57% Functions 2/7
25% Lines 10/40
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                                                                                              
define(["require", "exports", "../asn1/enumerator", "../asn1/abstract-syntax", "../asn1/unique-encoding-element", "../asn1/identifier-mapping"], function (require, exports, enumerator_1, abstract_syntax_1, unique_encoding_element_1, identifier_mapping_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var _PdfAlgorithms = (function () {
        function _PdfAlgorithms(element) {
            if (element) {
                this._element = element;
                var list = element._getSequence();
                if (!list || list.length < 1 || list.length > 2) {
                    throw new Error('Invalid Algorithm Identifier sequence length');
                }
                var oidElement = list[0];
                var oidBytes = oidElement._getValue();
                this._objectID = new identifier_mapping_1._PdfObjectIdentifier()._fromBytes(oidBytes);
                if (list.length === 2) {
                    this._parameters = list[1];
                    this._parametersDefined = true;
                }
                else {
                    this._parametersDefined = false;
                }
            }
        }
        _PdfAlgorithms.prototype._getAlgorithms = function (obj) {
            if (obj instanceof _PdfAlgorithms) {
                return obj;
            }
            if (obj instanceof abstract_syntax_1._PdfAbstractSyntaxElement) {
                return new _PdfAlgorithms(obj);
            }
            return undefined;
        };
        _PdfAlgorithms.prototype._uniqueEncoderEncode = function () {
            if (this._element) {
                return this._element._getValue();
            }
            throw new Error('Cannot DER encode: not a DER element');
        };
        _PdfAlgorithms.prototype._getUniqueEncoderNull = function () {
            var derNull = new unique_encoding_element_1._PdfUniqueEncodingElement();
            derNull._setTagNumber(5);
            derNull._tagClass = 0;
            derNull._setValue(new Uint8Array(0));
            return derNull;
        };
        _PdfAlgorithms.prototype._getAbstractSyntax = function () {
            var seq = new unique_encoding_element_1._PdfUniqueEncodingElement(enumerator_1._TagClassType.universal, enumerator_1._ConstructionType.constructed, enumerator_1._UniversalType.sequence);
            var oidElement = new unique_encoding_element_1._PdfUniqueEncodingElement(enumerator_1._TagClassType.universal, enumerator_1._ConstructionType.primitive, 6);
            var elements = [oidElement];
            seq._setSequence(elements);
            return seq;
        };
        return _PdfAlgorithms;
    }());
    exports._PdfAlgorithms = _PdfAlgorithms;
});