https
express server läuft jetzt mit https
This commit is contained in:
63
express-server/node_modules/asn1js/.gitattributes
generated
vendored
Normal file
63
express-server/node_modules/asn1js/.gitattributes
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
156
express-server/node_modules/asn1js/.npmignore
generated
vendored
Normal file
156
express-server/node_modules/asn1js/.npmignore
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
!packages/*/build/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
|
||||
#LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
1
express-server/node_modules/asn1js/CNAME
generated
vendored
Normal file
1
express-server/node_modules/asn1js/CNAME
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
asn1js.org
|
30
express-server/node_modules/asn1js/LICENSE
generated
vendored
Normal file
30
express-server/node_modules/asn1js/LICENSE
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
Copyright (c) 2014, GMO GlobalSign
|
||||
Copyright (c) 2015, Peculiar Ventures
|
||||
All rights reserved.
|
||||
|
||||
Author 2014-2015, Yury Strozhevsky
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
212
express-server/node_modules/asn1js/README.md
generated
vendored
Normal file
212
express-server/node_modules/asn1js/README.md
generated
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
## ASN1js
|
||||
|
||||
[](https://raw.githubusercontent.com/GlobalSign/ASN1.js/master/LICENSE)
|
||||
|
||||
Abstract Syntax Notation One (ASN.1) is a standard and notation that describes rules and structures for representing, encoding, transmitting, and decoding data in telecommunications and computer networking. [ASN1js][] is a pure JavaScript library implementing this standard. ASN.1 is the basis of all X.509 related data structures and numerous other protocols used on the web.
|
||||
|
||||
## Introduction
|
||||
|
||||
[ASN1js][] is the first library for [BER][] encoding/decoding in Javascript designed for browser use. [BER][] is the basic encoding rules for [ASN.1][] that all others are based on, [DER][] is the encoding rules used by PKI applications - it is a subset of [BER][]. The [ASN1js][] library was tested against [freely available ASN.1:2008 test suite], with some limitations related to JavaScript language.
|
||||
|
||||
## Features of the library
|
||||
|
||||
* [ASN1js][] is a "base layer" for full-featured JS library [PKIjs][], which is using Web Cryptography API and has all classes, neccessary to work with PKI-related data;
|
||||
* Fully object-oriented library. Inhiritence is using everywhere inside the lib;
|
||||
* Working with HTML5 data objects (ArrayBuffer, Uint8Array etc.);
|
||||
* Working with all ASN.1:2008 types;
|
||||
* Working with [BER][] encoded data;
|
||||
* All types inside the library constantly stores information about all ASN.1 sub blocks (tag block, length block or value block);
|
||||
* User may have access to any byte inside any ASN.1 sub-block;
|
||||
* Any sub-block may have unlimited length, as it described in ASN.1 standard (even "tag block");
|
||||
* Ability to work with ASN.1 string date types (intcluding all "international" strings like UniversalString, BMPString, UTF8String) by passing native JavaScript strings into constuctors. And vice versa - all initially parsed data of ASN.1 string types right after decoding automatically converts into native JavaScript strings;
|
||||
* Same with ASN.1 date-time types: for major types like UTCTime and GeneralizedTime there are automatic convertion between "JS date type - ASN.1 date-time type" + vice versa;
|
||||
* Same with ASN.1 OBJECT-IDENTIFIER (OID) data-type: you can initialize OID by JavaScript string and can get string representation via calling "oid.value_block.toString()";
|
||||
* Working with "easy-to-understand" ASN.1 schemas (pre-defined or built by user);
|
||||
* Has special types to work with ASN.1 schemas:
|
||||
* ANY
|
||||
* CHOICE
|
||||
* REPEATED
|
||||
* User can name any block inside ASN.1 schema and easily get information by name;
|
||||
* Ability to parse internal data inside a primitively encoded data types and automatically validate it against special schema;
|
||||
* All types inside library are dynamic;
|
||||
* All types can be initialized in static or dynamic ways.
|
||||
|
||||
## Examples
|
||||
|
||||
```javascript
|
||||
// #region How to create new ASN. structures
|
||||
var sequence = new org.pkijs.asn1.SEQUENCE();
|
||||
sequence.value_block.value.push(new org.pkijs.asn1.INTEGER({ value: 1 }));
|
||||
|
||||
var sequence_buffer = sequence.toBER(false); // Encode current sequence to BER (in ArrayBuffer)
|
||||
var current_size = sequence_buffer.byteLength;
|
||||
|
||||
var integer_data = new ArrayBuffer(8);
|
||||
var integer_view = new Uint8Array(integer_data);
|
||||
integer_view[0] = 0x01;
|
||||
integer_view[1] = 0x01;
|
||||
integer_view[2] = 0x01;
|
||||
integer_view[3] = 0x01;
|
||||
integer_view[4] = 0x01;
|
||||
integer_view[5] = 0x01;
|
||||
integer_view[6] = 0x01;
|
||||
integer_view[7] = 0x01;
|
||||
|
||||
sequence.value_block.value.push(new org.pkijs.asn1.INTEGER({
|
||||
is_hex_only: true,
|
||||
value_hex: integer_data
|
||||
})); // Put too long for decoding INTEGER value
|
||||
|
||||
sequence_buffer = sequence.toBER(false);
|
||||
current_size = sequence_buffer.byteLength;
|
||||
// #endregion
|
||||
```
|
||||
|
||||
```javascript
|
||||
// #region How to create new ASN.1 structures by calling constuctors with parameters
|
||||
var sequence2 = new org.pkijs.asn1.SEQUENCE({
|
||||
value: [
|
||||
new org.pkijs.asn1.INTEGER({ value: 1 }),
|
||||
new org.pkijs.asn1.INTEGER({
|
||||
is_hex_only: true,
|
||||
value_hex: integer_data
|
||||
}),
|
||||
]
|
||||
});
|
||||
// #endregion
|
||||
```
|
||||
|
||||
```javascript
|
||||
// #region How to validate ASN.1 against pre-defined schema
|
||||
var asn1_schema = new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.NULL({
|
||||
name: "block2"
|
||||
}),
|
||||
new org.pkijs.asn1.INTEGER({
|
||||
name: "block3",
|
||||
optional: true // This block is absent inside data, but it's "optional". Hence verification against the schema will be passed.
|
||||
})
|
||||
]
|
||||
});
|
||||
// #endregion
|
||||
|
||||
var variant1 = org.pkijs.verifySchema(encoded_sequence, asn1_schema); // Verify schema together with decoding of raw data
|
||||
var variant1_verified = variant1.verified;
|
||||
var variant1_result = variant1.result; // Verified decoded data with all block names inside
|
||||
```
|
||||
|
||||
```javascript
|
||||
// #region How to use "internal schemas" for primitevely encoded data types
|
||||
var primitive_octetstring = new org.pkijs.asn1.OCTETSTRING({ value_hex: encoded_sequence }); // Create a primitively encoded OCTETSTRING where internal data is an encoded SEQUENCE
|
||||
|
||||
var asn1_schema_internal = new org.pkijs.asn1.OCTETSTRING({
|
||||
name: "outer_block",
|
||||
primitive_schema: new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.NULL({
|
||||
name: "block2"
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
var variant6 = org.pkijs.compareSchema(primitive_octetstring, primitive_octetstring, asn1_schema_internal);
|
||||
var variant6_verified = variant4.verified;
|
||||
var variant6_block1_tag_num = variant6.result.block1.id_block.tag_number;
|
||||
var variant6_block2_tag_num = variant6.result.block2.id_block.tag_number;
|
||||
// #endregion
|
||||
```
|
||||
|
||||
More examples could be found in "examples" directory or inside [PKIjs][] library.
|
||||
|
||||
## Related source code
|
||||
|
||||
* [C++ ASN1:2008 BER coder/decoder](https://github.com/YuryStrozhevsky/C-plus-plus-ASN.1-2008-coder-decoder) - the "father" of [ASN1js][] project;
|
||||
* [Freely available ASN.1:2008 test suite](https://github.com/YuryStrozhevsky/ASN1-2008-free-test-suite) - the suite which can help you to validate (and better understand) any ASN.1 coder/decoder;
|
||||
|
||||
## Suitability
|
||||
At this time this library should be considered suitable for research and experimentation, futher code and security review is needed before utilization in a production application.
|
||||
|
||||
## How to use ASN1js and PKIjs with Node.js
|
||||
|
||||
**!!! WARNING !!! **
|
||||
**Currently there is no "polyfill" of WebCrypto in Node.js. Thus you will not be able to use signature / verification features of PKIjs in Node.js programs.**
|
||||
|
||||
In order to use [PKIjs][] you will also need [ASN1js][] plus [node.extend](https://www.npmjs.com/package/node.extend) package.
|
||||
```javascript
|
||||
var merge = require("node.extend");
|
||||
|
||||
var common = require("asn1js/org/pkijs/common");
|
||||
var _asn1js = require("asn1js");
|
||||
var _pkijs = require("pkijs");
|
||||
var _x509schema = require("pkijs/org/pkijs/x509_schema");
|
||||
|
||||
// #region Merging function/object declarations for ASN1js and PKIjs
|
||||
var asn1js = merge(true, _asn1js, common);
|
||||
|
||||
var x509schema = merge(true, _x509schema, asn1js);
|
||||
|
||||
var pkijs_1 = merge(true, _pkijs, asn1js);
|
||||
var pkijs = merge(true, pkijs_1, x509schema);
|
||||
// #endregion
|
||||
```
|
||||
|
||||
After that you will ba able to use ASN1js and PKIjs via common way:
|
||||
```javascript
|
||||
// #region Decode and parse X.509 cert
|
||||
var asn1 = pkijs.org.pkijs.fromBER(certBuffer);
|
||||
var cert;
|
||||
try
|
||||
{
|
||||
cert = new pkijs.org.pkijs.simpl.CERT({ schema: asn1.result });
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// #endregion
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2014, [GMO GlobalSign](http://www.globalsign.com/)
|
||||
Copyright (c) 2015, [Peculiar Ventures](http://peculiarventures.com/)
|
||||
All rights reserved.
|
||||
|
||||
Author 2014-2015, [Yury Strozhevsky](http://www.strozhevsky.com/).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
|
||||
|
||||
[ASN.1]: http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One
|
||||
[ASN1js]: http://asn1js.org/
|
||||
[PKIjs]: http://pkijs.org/
|
||||
[BER]: http://en.wikipedia.org/wiki/X.690#BER_encoding
|
||||
[DER]: http://en.wikipedia.org/wiki/X.690#DER_encoding
|
||||
[freely available ASN.1:2008 test suite]: http://www.strozhevsky.com/free_docs/free_asn1_testsuite_descr.pdf
|
240
express-server/node_modules/asn1js/examples/ASN.1 usage/asn1_usage.js
generated
vendored
Normal file
240
express-server/node_modules/asn1js/examples/ASN.1 usage/asn1_usage.js
generated
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2014, GMO GlobalSign
|
||||
* Copyright (c) 2015, Peculiar Ventures
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author 2014-2015, Yury Strozhevsky <www.strozhevsky.com>.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
//**************************************************************************************
|
||||
function test()
|
||||
{
|
||||
// #region How to create new ASN. structures
|
||||
var sequence = new org.pkijs.asn1.SEQUENCE();
|
||||
sequence.value_block.value.push(new org.pkijs.asn1.INTEGER({ value: 1 }));
|
||||
|
||||
var sequence_buffer = sequence.toBER(false); // Encode current sequence to BER (in ArrayBuffer)
|
||||
var current_size = sequence_buffer.byteLength;
|
||||
|
||||
var integer_data = new ArrayBuffer(8);
|
||||
var integer_view = new Uint8Array(integer_data);
|
||||
integer_view[0] = 0x01;
|
||||
integer_view[1] = 0x01;
|
||||
integer_view[2] = 0x01;
|
||||
integer_view[3] = 0x01;
|
||||
integer_view[4] = 0x01;
|
||||
integer_view[5] = 0x01;
|
||||
integer_view[6] = 0x01;
|
||||
integer_view[7] = 0x01;
|
||||
|
||||
sequence.value_block.value.push(new org.pkijs.asn1.INTEGER({
|
||||
is_hex_only: true,
|
||||
value_hex: integer_data
|
||||
})); // Put too long for decoding INTEGER value
|
||||
|
||||
sequence_buffer = sequence.toBER(false);
|
||||
current_size = sequence_buffer.byteLength;
|
||||
// #endregion
|
||||
|
||||
// #region How to create new ASN.1 structures by calling constuctors with parameters
|
||||
var sequence2 = new org.pkijs.asn1.SEQUENCE({
|
||||
value: [
|
||||
new org.pkijs.asn1.INTEGER({ value: 1 }),
|
||||
new org.pkijs.asn1.INTEGER({
|
||||
is_hex_only: true,
|
||||
value_hex: integer_data
|
||||
}),
|
||||
]
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// #region How to check that decoded value is too big
|
||||
var big_integer_value;
|
||||
|
||||
var big_integer = new org.pkijs.asn1.INTEGER({
|
||||
is_hex_only: true,
|
||||
value_hex: integer_data
|
||||
});
|
||||
|
||||
if(big_integer.value_block.is_hex_only === false)
|
||||
big_integer_value = big_integer.value_block.value_dec; // Native integer value
|
||||
else
|
||||
big_integer_value = big_integer.value_block.value_hex; // ArrayBuffer
|
||||
// #endregion
|
||||
|
||||
// #region How to get ASN.1 structures from raw data (ASN.1 decoding)
|
||||
var encoded_sequence = new ArrayBuffer(4);
|
||||
var encoded_sequence_view = new Uint8Array(encoded_sequence);
|
||||
encoded_sequence_view[0] = 0x30;
|
||||
encoded_sequence_view[1] = 0x02;
|
||||
encoded_sequence_view[2] = 0x05;
|
||||
encoded_sequence_view[3] = 0x00;
|
||||
|
||||
var decoded_asn1 = org.pkijs.fromBER(encoded_sequence);
|
||||
if(decoded_asn1.offset === (-1))
|
||||
return; // Error during decoding
|
||||
|
||||
var decoded_sequence = decoded_asn1.result;
|
||||
|
||||
var internal_value = decoded_sequence.value_block.value[0];
|
||||
var internal_value_tag_number = internal_value.id_block.tag_number; // Value of "5" equal to ASN.1 NULL type
|
||||
// #endregion
|
||||
|
||||
// #region How to work with ASN.1 strings
|
||||
var bmp_string_encoded = new ArrayBuffer(16); // This ArrayBuffer consinsts of encoded ASN.1 BMPString with "abc_" + three first chars from Russian alphabet
|
||||
var bmp_string_view = new Uint8Array(bmp_string_encoded);
|
||||
bmp_string_view[0] = 0x1E;
|
||||
bmp_string_view[1] = 0x0E;
|
||||
bmp_string_view[2] = 0x00;
|
||||
bmp_string_view[3] = 0x61;
|
||||
bmp_string_view[4] = 0x00;
|
||||
bmp_string_view[5] = 0x62;
|
||||
bmp_string_view[6] = 0x00;
|
||||
bmp_string_view[7] = 0x63;
|
||||
bmp_string_view[8] = 0x00;
|
||||
bmp_string_view[9] = 0x5F;
|
||||
bmp_string_view[10] = 0x04;
|
||||
bmp_string_view[11] = 0x30;
|
||||
bmp_string_view[12] = 0x04;
|
||||
bmp_string_view[13] = 0x31;
|
||||
bmp_string_view[14] = 0x04;
|
||||
bmp_string_view[15] = 0x32;
|
||||
|
||||
var bmp_string_decoded = org.pkijs.fromBER(bmp_string_encoded);
|
||||
if(bmp_string_decoded.offset === (-1))
|
||||
return; // Error during decoding
|
||||
|
||||
var javascript_string1 = bmp_string_decoded.result.value_block.value;
|
||||
|
||||
var bmp_string = new org.pkijs.asn1.BMPSTRING({ value: "abc_абв" }); // Same with initialization by static JavaScript string
|
||||
var javascript_string2 = bmp_string.value_block.value;
|
||||
// #endregion
|
||||
|
||||
// #region How to validate ASN.1 against pre-defined schema
|
||||
var asn1_schema = new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.NULL({
|
||||
name: "block2"
|
||||
}),
|
||||
new org.pkijs.asn1.INTEGER({
|
||||
name: "block3",
|
||||
optional: true // This block is absent inside data, but it's "optional". Hence verification against the schema will be passed.
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
var variant1 = org.pkijs.verifySchema(encoded_sequence, asn1_schema); // Verify schema together with decoding of raw data
|
||||
var variant1_verified = variant1.verified;
|
||||
var variant1_result = variant1.result; // Verified decoded data with all block names inside
|
||||
|
||||
var variant1_block1 = variant1_result.block1;
|
||||
var variant1_block2 = variant1_result.block2;
|
||||
|
||||
var variant2 = org.pkijs.compareSchema(decoded_sequence, decoded_sequence, asn1_schema); // Compare already decoded ASN.1 against pre-defined schema
|
||||
var variant2_verified = variant2.verified;
|
||||
var variant2_result = variant2.result; // Verified decoded data with all block names inside
|
||||
|
||||
var variant2_block1 = variant2_result.block1;
|
||||
var variant2_block2 = variant2_result.block2;
|
||||
|
||||
var asn1_schema_any = new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.ANY({ // Special type, for ASN.1 schemas only - will validate schema against any ASN.1 type
|
||||
name: "block2"
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
decoded_sequence = org.pkijs.fromBER(encoded_sequence).result; // Re-setting "decoded_sequence"
|
||||
|
||||
var variant3 = org.pkijs.compareSchema(decoded_sequence, decoded_sequence, asn1_schema_any);
|
||||
var variant3_verified = variant3.verified;
|
||||
|
||||
var asn1_schema_repeated = new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.REPEATED({ // Special type, for ASN.1 schemas only - will check that inside decoded data there are sequence of values with one type only
|
||||
name: "block2_array",
|
||||
value: new org.pkijs.asn1.NULL()
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
decoded_sequence = org.pkijs.fromBER(encoded_sequence).result; // Re-setting "decoded_sequence"
|
||||
|
||||
var variant4 = org.pkijs.compareSchema(decoded_sequence, decoded_sequence, asn1_schema_repeated);
|
||||
var variant4_verified = variant4.verified;
|
||||
|
||||
var variant4_array = variant4.block2_array; // Array of internal blocks
|
||||
|
||||
var asn1_schema_choice = new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.CHOICE({ // Special type, for ASN.1 schemas only - will check ASN.1 data has one of type
|
||||
value: [
|
||||
new org.pkijs.asn1.NULL({
|
||||
name: "block2"
|
||||
}),
|
||||
new org.pkijs.asn1.INTEGER({
|
||||
name: "block2"
|
||||
}),
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
decoded_sequence = org.pkijs.fromBER(encoded_sequence).result; // Re-setting "decoded_sequence"
|
||||
|
||||
var variant5 = org.pkijs.compareSchema(decoded_sequence, decoded_sequence, asn1_schema_choice);
|
||||
var variant5_verified = variant4.verified;
|
||||
// #endregion
|
||||
|
||||
// #region How to use "internal schemas" for primitevely encoded data types
|
||||
var primitive_octetstring = new org.pkijs.asn1.OCTETSTRING({ value_hex: encoded_sequence }); // Create a primitively encoded OCTETSTRING where internal data is an encoded SEQUENCE
|
||||
|
||||
var asn1_schema_internal = new org.pkijs.asn1.OCTETSTRING({
|
||||
name: "outer_block",
|
||||
primitive_schema: new org.pkijs.asn1.SEQUENCE({
|
||||
name: "block1",
|
||||
value: [
|
||||
new org.pkijs.asn1.NULL({
|
||||
name: "block2"
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
var variant6 = org.pkijs.compareSchema(primitive_octetstring, primitive_octetstring, asn1_schema_internal);
|
||||
var variant6_verified = variant4.verified;
|
||||
var variant6_block1_tag_num = variant6.result.block1.id_block.tag_number;
|
||||
var variant6_block2_tag_num = variant6.result.block2.id_block.tag_number;
|
||||
// #endregion
|
||||
}
|
||||
//**************************************************************************************
|
5466
express-server/node_modules/asn1js/org/pkijs/asn1.js
generated
vendored
Normal file
5466
express-server/node_modules/asn1js/org/pkijs/asn1.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1541
express-server/node_modules/asn1js/org/pkijs/common.js
generated
vendored
Normal file
1541
express-server/node_modules/asn1js/org/pkijs/common.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
94
express-server/node_modules/asn1js/package.json
generated
vendored
Normal file
94
express-server/node_modules/asn1js/package.json
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"asn1js@^1.2.12",
|
||||
"/nodeapps/https-test/greenlock-express.js/node_modules/certpem"
|
||||
]
|
||||
],
|
||||
"_from": "asn1js@>=1.2.12 <2.0.0",
|
||||
"_id": "asn1js@1.2.12",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/asn1js",
|
||||
"_nodeVersion": "5.8.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/asn1js-1.2.12.tgz_1460549801979_0.2164379085879773"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "yury@strozhevsky.com",
|
||||
"name": "yury.strozhevsky"
|
||||
},
|
||||
"_npmVersion": "3.7.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "asn1js",
|
||||
"raw": "asn1js@^1.2.12",
|
||||
"rawSpec": "^1.2.12",
|
||||
"scope": null,
|
||||
"spec": ">=1.2.12 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/certpem"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/asn1js/-/asn1js-1.2.12.tgz",
|
||||
"_shasum": "87d5ee797596ae2d2a3cb0247220dc42ffc3f211",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "asn1js@^1.2.12",
|
||||
"_where": "/nodeapps/https-test/greenlock-express.js/node_modules/certpem",
|
||||
"author": {
|
||||
"email": "yury@strozhevsky.com",
|
||||
"name": "Yury Strozhevsky"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/GlobalSign/ASN1.js/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Ryan Hurst",
|
||||
"email": "rmh@unmitigatedrisk.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "ASN1js is a pure JavaScript library implementing this standard. ASN.1 is the basis of all X.509 related data structures and numerous other protocols used on the web",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "87d5ee797596ae2d2a3cb0247220dc42ffc3f211",
|
||||
"tarball": "https://registry.npmjs.org/asn1js/-/asn1js-1.2.12.tgz"
|
||||
},
|
||||
"gitHead": "766534d2109c0e9ccc72d9b094eef50efe007925",
|
||||
"homepage": "https://github.com/GlobalSign/ASN1.js#readme",
|
||||
"keywords": [
|
||||
"asn.1",
|
||||
"asn1",
|
||||
"ber",
|
||||
"bitstring",
|
||||
"bmpstring",
|
||||
"der",
|
||||
"generalizedtime",
|
||||
"octetstring",
|
||||
"sequence",
|
||||
"set",
|
||||
"universalstring",
|
||||
"utctime",
|
||||
"utf8string"
|
||||
],
|
||||
"main": "org/pkijs/asn1.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "yury.strozhevsky",
|
||||
"email": "yury@strozhevsky.com"
|
||||
}
|
||||
],
|
||||
"name": "asn1js",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/GlobalSign/ASN1.js.git"
|
||||
},
|
||||
"scripts": {},
|
||||
"version": "1.2.12"
|
||||
}
|
Reference in New Issue
Block a user