diff --git a/org/pkijs/asn1.js b/org/pkijs/asn1.js
index ae93ee4..248e7fd 100644
--- a/org/pkijs/asn1.js
+++ b/org/pkijs/asn1.js
@@ -360,11 +360,24 @@ function(in_window)
{
/// General class of all ASN.1 blocks
- this.block_length = 0;
- this.error = new String();
- this.warnings = new Array();
- /// Copy of the value of incoming ArrayBuffer done before decoding
- this.value_before_decode = new ArrayBuffer(0);
+ if(arguments[0] instanceof Object)
+ {
+ this.block_length = in_window.org.pkijs.getValue(arguments[0], "block_length", 0);
+ this.error = in_window.org.pkijs.getValue(arguments[0], "error", new String());
+ this.warnings = in_window.org.pkijs.getValue(arguments[0], "warnings", new Array());
+ if("value_before_decode" in arguments[0])
+ this.value_before_decode = util_copybuf(arguments[0].value_before_decode);
+ else
+ this.value_before_decode = new ArrayBuffer(0);
+ }
+ else
+ {
+ this.block_length = 0;
+ this.error = new String();
+ this.warnings = new Array();
+ /// Copy of the value of incoming ArrayBuffer done before decoding
+ this.value_before_decode = new ArrayBuffer(0);
+ }
}
//**************************************************************************************
local.base_block.prototype.block_name =
@@ -372,7 +385,21 @@ function(in_window)
{
/// Aux function, need to get a block name. Need to have it here for inhiritence
- return "identification_block";
+ return "base_block";
+ }
+ //**************************************************************************************
+ local.base_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ return {
+ block_name: local.base_block.prototype.block_name.call(this),
+ block_length: this.block_length,
+ error: this.error,
+ warnings: this.warnings,
+ value_before_decode: in_window.org.pkijs.bufferToHexCodes(this.value_before_decode, 0, this.value_before_decode.byteLength)
+ };
}
//**************************************************************************************
// #endregion
@@ -479,6 +506,20 @@ function(in_window)
return ret_buf;
}
//**************************************************************************************
+ local.hex_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.base_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.hex_block.prototype.block_name.call(this);
+ _object.is_hex_only = this.is_hex_only;
+ _object.value_hex = in_window.org.pkijs.bufferToHexCodes(this.value_hex, 0, this.value_hex.byteLength)
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of identification block class
@@ -775,6 +816,21 @@ function(in_window)
return ( input_offset + this.block_length ); // Return current offset in input buffer
}
//**************************************************************************************
+ local.identification_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.hex_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.identification_block.prototype.block_name.call(this);
+ _object.tag_class = this.tag_class;
+ _object.tag_number = this.tag_number;
+ _object.is_constructed = this.is_constructed;
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of length block class
@@ -975,6 +1031,21 @@ function(in_window)
return (new ArrayBuffer(0));
}
//**************************************************************************************
+ local.length_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.base_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.length_block.prototype.block_name.call(this);
+ _object.is_indefinite_form = this.is_indefinite_form;
+ _object.long_form_used = this.long_form_used;
+ _object.length = this.length;
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of value block class
@@ -997,6 +1068,18 @@ function(in_window)
return "value_block";
}
//**************************************************************************************
+ local.value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.base_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.value_block.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of basic ASN.1 block class
@@ -1106,6 +1189,28 @@ function(in_window)
return ret_buf;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.base_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.ASN1_block.prototype.block_name.call(this);
+ _object.id_block = this.id_block.toJSON();
+ _object.len_block = this.len_block.toJSON();
+ _object.value_block = this.value_block.toJSON();
+
+ if("name" in this)
+ _object.name = this.name;
+ if("optional" in this)
+ _object.optional = this.optional;
+ if("primitive_schema" in this)
+ _object.primitive_schema = this.primitive_schema.toJSON();
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of basic block for all PRIMITIVE types
@@ -1187,6 +1292,28 @@ function(in_window)
return util_copybuf(this.value_hex);
}
//**************************************************************************************
+ local.ASN1_PRIMITIVE_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "ASN1_PRIMITIVE_value_block";
+ }
+ //**************************************************************************************
+ local.ASN1_PRIMITIVE_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.ASN1_PRIMITIVE_value_block.prototype.block_name.call(this);
+ _object.value_hex = in_window.org.pkijs.bufferToHexCodes(this.value_hex, 0, this.value_hex.byteLength);
+ _object.is_hex_only = this.is_hex_only;
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.ASN1_PRIMITIVE =
function()
{
@@ -1209,6 +1336,18 @@ function(in_window)
return "PRIMITIVE";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.ASN1_PRIMITIVE.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.ASN1_PRIMITIVE.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of basic block for all CONSTRUCTED types
@@ -1333,6 +1472,30 @@ function(in_window)
return ret_buf;
}
//**************************************************************************************
+ local.ASN1_CONSTRUCTED_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "ASN1_CONSTRUCTED_value_block";
+ }
+ //**************************************************************************************
+ local.ASN1_CONSTRUCTED_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.ASN1_CONSTRUCTED_value_block.prototype.block_name.call(this);
+ _object.is_indefinite_form = this.is_indefinite_form;
+ _object.value = new Array();
+ for(var i = 0; i < this.value.length; i++)
+ _object.value.push(this.value[i].toJSON());
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.ASN1_CONSTRUCTED =
function()
{
@@ -1384,6 +1547,18 @@ function(in_window)
return result_offset;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 EOC type class
@@ -1419,6 +1594,26 @@ function(in_window)
return (new ArrayBuffer(0));
}
//**************************************************************************************
+ local.EOC_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "EOC_value_block";
+ }
+ //**************************************************************************************
+ local.EOC_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.EOC_value_block.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.EOC =
function()
{
@@ -1441,6 +1636,18 @@ function(in_window)
return "END_OF_CONTENT";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.EOC.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.EOC.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 BOOLEAN type class
@@ -1535,6 +1742,29 @@ function(in_window)
return this.value_hex;
}
//**************************************************************************************
+ local.BOOLEAN_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "BOOLEAN_value_block";
+ }
+ //**************************************************************************************
+ local.BOOLEAN_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.BOOLEAN_value_block.prototype.block_name.call(this);
+ _object.value = this.value;
+ _object.is_hex_only = this.is_hex_only;
+ _object.value_hex = in_window.org.pkijs.bufferToHexCodes(this.value_hex, 0, this.value_hex.byteLength)
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.BOOLEAN =
function()
{
@@ -1557,6 +1787,18 @@ function(in_window)
return "BOOLEAN";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.BOOLEAN.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.BOOLEAN.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 SEQUENCE and SET type classes
@@ -1581,6 +1823,18 @@ function(in_window)
return "SEQUENCE";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.SEQUENCE.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.SEQUENCE.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.SET =
function()
{
@@ -1601,6 +1855,18 @@ function(in_window)
return "SET";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.SET.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.SET.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 NULL type class
@@ -1668,6 +1934,18 @@ function(in_window)
return ret_buf;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.NULL.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.NULL.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 OCTETSTRING type class
@@ -1789,6 +2067,29 @@ function(in_window)
return (new ArrayBuffer(0));
}
//**************************************************************************************
+ local.OCTETSTRING_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "OCTETSTRING_value_block";
+ }
+ //**************************************************************************************
+ local.OCTETSTRING_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.ASN1_CONSTRUCTED_value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.OCTETSTRING_value_block.prototype.block_name.call(this);
+ _object.is_constructed = this.is_constructed;
+ _object.is_hex_only = this.is_hex_only;
+ _object.value_hex = in_window.org.pkijs.bufferToHexCodes(this.value_hex, 0, this.value_hex.byteLength)
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.OCTETSTRING =
function()
{
@@ -1828,6 +2129,18 @@ function(in_window)
return "OCTETSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.OCTETSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.OCTETSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 BITSTRING type class
@@ -2002,6 +2315,30 @@ function(in_window)
return (new ArrayBuffer(0));
}
//**************************************************************************************
+ local.BITSTRING_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "BITSTRING_value_block";
+ }
+ //**************************************************************************************
+ local.BITSTRING_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.ASN1_CONSTRUCTED_value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.BITSTRING_value_block.prototype.block_name.call(this);
+ _object.unused_bits = this.unused_bits;
+ _object.is_constructed = this.is_constructed;
+ _object.is_hex_only = this.is_hex_only;
+ _object.value_hex = in_window.org.pkijs.bufferToHexCodes(this.value_hex, 0, this.value_hex.byteLength)
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.BITSTRING =
function()
{
@@ -2043,6 +2380,18 @@ function(in_window)
return in_window.org.pkijs.asn1.ASN1_block.prototype.fromBER.call(this, input_buffer, input_offset, input_length);
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.BITSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.BITSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 INTEGER type class
@@ -2136,6 +2485,29 @@ function(in_window)
return (new ArrayBuffer(0));
}
//**************************************************************************************
+ local.INTEGER_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "INTEGER_value_block";
+ }
+ //**************************************************************************************
+ local.INTEGER_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.INTEGER_value_block.prototype.block_name.call(this);
+ _object.value_dec = this.value_dec;
+ _object.is_hex_only = this.is_hex_only;
+ _object.value_hex = in_window.org.pkijs.bufferToHexCodes(this.value_hex, 0, this.value_hex.byteLength)
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.INTEGER =
function()
{
@@ -2187,6 +2559,18 @@ function(in_window)
return false;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.INTEGER.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.INTEGER.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 ENUMERATED type class
@@ -2203,6 +2587,26 @@ function(in_window)
in_window.org.pkijs.asn1.ENUMERATED.prototype = new in_window.org.pkijs.asn1.INTEGER();
in_window.org.pkijs.asn1.ENUMERATED.constructor = in_window.org.pkijs.asn1.ENUMERATED;
//**************************************************************************************
+ in_window.org.pkijs.asn1.ENUMERATED.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "ENUMERATED";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.ENUMERATED.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.INTEGER.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.ENUMERATED.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of ASN.1 OBJECT IDENTIFIER type class
@@ -2383,6 +2787,20 @@ function(in_window)
return result;
}
//**************************************************************************************
+ local.SID_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.hex_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.SID_value_block.prototype.block_name.call(this);
+ _object.value_dec = this.value_dec;
+ _object.is_first_sid = this.is_first_sid;
+
+ return _object;
+ }
+ //**************************************************************************************
local.OID_value_block =
function()
{
@@ -2553,6 +2971,30 @@ function(in_window)
return result;
}
//**************************************************************************************
+ local.OID_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "OID_value_block";
+ }
+ //**************************************************************************************
+ local.OID_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.value_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.OID_value_block.prototype.block_name.call(this);
+ _object.value = local.OID_value_block.prototype.toString.call(this);
+ _object.sid_array = new Array();
+ for(var i = 0; i < this.value.length; i++)
+ _object.sid_array.push(this.value[i].toJSON());
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.OID =
function()
{
@@ -2567,6 +3009,26 @@ function(in_window)
in_window.org.pkijs.asn1.OID.prototype = new in_window.org.pkijs.asn1.ASN1_block();
in_window.org.pkijs.asn1.OID.constructor = in_window.org.pkijs.asn1.OID;
//**************************************************************************************
+ in_window.org.pkijs.asn1.OID.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "OID";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.OID.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.OID.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of all string's classes
@@ -2583,6 +3045,27 @@ function(in_window)
local.UTF8STRING_value_block.prototype = new local.hex_block();
local.UTF8STRING_value_block.constructor = local.UTF8STRING_value_block;
//**************************************************************************************
+ local.UTF8STRING_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "UTF8STRING_value_block";
+ }
+ //**************************************************************************************
+ local.UTF8STRING_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.hex_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.UTF8STRING_value_block.prototype.block_name.call(this);
+ _object.value = this.value;
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.UTF8STRING =
function()
{
@@ -2644,8 +3127,16 @@ function(in_window)
function(input_buffer)
{
/// Array with encoded string
+ this.value_block.value = String.fromCharCode.apply(null, new Uint8Array(input_buffer));
- this.value_block.value = decodeURIComponent(escape(String.fromCharCode.apply(null, new Uint8Array(input_buffer))));
+ try
+ {
+ this.value_block.value = decodeURIComponent(escape(this.value_block.value));
+ }
+ catch(ex)
+ {
+ this.warnings.push("Error during \"decodeURIComponent\": " + ex + ", using raw string");
+ }
}
//**************************************************************************************
in_window.org.pkijs.asn1.UTF8STRING.prototype.fromString =
@@ -2665,17 +3156,51 @@ function(in_window)
this.value_block.value = input_string;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.UTF8STRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.UTF8STRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
local.BMPSTRING_value_block =
function()
{
local.hex_block.call(this, arguments[0]);
this.is_hex_only = true;
+ this.value = "";
}
//**************************************************************************************
local.BMPSTRING_value_block.prototype = new local.hex_block();
local.BMPSTRING_value_block.constructor = local.BMPSTRING_value_block;
//**************************************************************************************
+ local.BMPSTRING_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "BMPSTRING_value_block";
+ }
+ //**************************************************************************************
+ local.BMPSTRING_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.hex_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.BMPSTRING_value_block.prototype.block_name.call(this);
+ _object.value = this.value;
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.BMPSTRING =
function()
{
@@ -2779,17 +3304,51 @@ function(in_window)
this.value_block.value = input_string;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.BMPSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.BMPSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
local.UNIVERSALSTRING_value_block =
function()
{
local.hex_block.call(this, arguments[0]);
this.is_hex_only = true;
+ this.value = "";
}
//**************************************************************************************
local.UNIVERSALSTRING_value_block.prototype = new local.hex_block();
local.UNIVERSALSTRING_value_block.constructor = local.UNIVERSALSTRING_value_block;
//**************************************************************************************
+ local.UNIVERSALSTRING_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "UNIVERSALSTRING_value_block";
+ }
+ //**************************************************************************************
+ local.UNIVERSALSTRING_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.hex_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.UNIVERSALSTRING_value_block.prototype.block_name.call(this);
+ _object.value = this.value;
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.UNIVERSALSTRING =
function()
{
@@ -2893,6 +3452,18 @@ function(in_window)
this.value_block.value = input_string;
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.UNIVERSALSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.UNIVERSALSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
local.SIMPLESTRING_value_block =
function()
{
@@ -2906,6 +3477,27 @@ function(in_window)
local.SIMPLESTRING_value_block.prototype = new local.hex_block();
local.SIMPLESTRING_value_block.constructor = local.SIMPLESTRING_value_block;
//**************************************************************************************
+ local.SIMPLESTRING_value_block.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "SIMPLESTRING_value_block";
+ }
+ //**************************************************************************************
+ local.SIMPLESTRING_value_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.hex_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.SIMPLESTRING_value_block.prototype.block_name.call(this);
+ _object.value = this.value;
+
+ return _object;
+ }
+ //**************************************************************************************
local.SIMPLESTRING_block =
function()
{
@@ -2983,6 +3575,19 @@ function(in_window)
this.value_block.value = input_string;
}
//**************************************************************************************
+ local.SIMPLESTRING_block.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);
+
+ _object.block_name = local.SIMPLESTRING_block.prototype.block_name.call(this);
+ _object.block_name = local.value_block.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.NUMERICSTRING =
function()
{
@@ -3003,6 +3608,18 @@ function(in_window)
return "NUMERICSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.NUMERICSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.NUMERICSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.PRINTABLESTRING =
function()
{
@@ -3023,6 +3640,18 @@ function(in_window)
return "PRINTABLESTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.PRINTABLESTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.PRINTABLESTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.TELETEXSTRING =
function()
{
@@ -3043,6 +3672,18 @@ function(in_window)
return "TELETEXSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.TELETEXSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.TELETEXSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.VIDEOTEXSTRING =
function()
{
@@ -3063,6 +3704,18 @@ function(in_window)
return "VIDEOTEXSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.VIDEOTEXSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.VIDEOTEXSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.IA5STRING =
function()
{
@@ -3083,6 +3736,18 @@ function(in_window)
return "IA5STRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.IA5STRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.IA5STRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.GRAPHICSTRING =
function()
{
@@ -3103,6 +3768,18 @@ function(in_window)
return "GRAPHICSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.GRAPHICSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.GRAPHICSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.VISIBLESTRING =
function()
{
@@ -3123,6 +3800,18 @@ function(in_window)
return "VISIBLESTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.VISIBLESTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.VISIBLESTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.GENERALSTRING =
function()
{
@@ -3143,6 +3832,18 @@ function(in_window)
return "GENERALSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.GENERALSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.GENERALSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.CHARACTERSTRING =
function()
{
@@ -3163,6 +3864,18 @@ function(in_window)
return "CHARACTERSTRING";
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.CHARACTERSTRING.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = local.SIMPLESTRING_block.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.CHARACTERSTRING.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of all date and time classes
@@ -3320,6 +4033,32 @@ function(in_window)
return output_array.join('');
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.UTCTIME.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "UTCTIME";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.UTCTIME.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.VISIBLESTRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.UTCTIME.prototype.block_name.call(this);
+ _object.year = this.year;
+ _object.month = this.month;
+ _object.day = this.day;
+ _object.hour = this.hour;
+ _object.minute = this.minute;
+ _object.second = this.second;
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.GENERALIZEDTIME =
function()
{
@@ -3464,6 +4203,32 @@ function(in_window)
return output_array.join('');
}
//**************************************************************************************
+ in_window.org.pkijs.asn1.GENERALIZEDTIME.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "GENERALIZEDTIME";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.GENERALIZEDTIME.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.VISIBLESTRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.GENERALIZEDTIME.prototype.block_name.call(this);
+ _object.year = this.year;
+ _object.month = this.month;
+ _object.day = this.day;
+ _object.hour = this.hour;
+ _object.minute = this.minute;
+ _object.second = this.second;
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.DATE =
function()
{
@@ -3476,6 +4241,26 @@ function(in_window)
in_window.org.pkijs.asn1.DATE.prototype = new in_window.org.pkijs.asn1.UTF8STRING();
in_window.org.pkijs.asn1.DATE.constructor = in_window.org.pkijs.asn1.DATE;
//**************************************************************************************
+ in_window.org.pkijs.asn1.DATE.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "DATE";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.DATE.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.DATE.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.TIMEOFDAY =
function()
{
@@ -3485,6 +4270,26 @@ function(in_window)
in_window.org.pkijs.asn1.TIMEOFDAY.prototype = new in_window.org.pkijs.asn1.UTF8STRING();
in_window.org.pkijs.asn1.TIMEOFDAY.constructor = in_window.org.pkijs.asn1.TIMEOFDAY;
//**************************************************************************************
+ in_window.org.pkijs.asn1.TIMEOFDAY.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "TIMEOFDAY";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.DATE.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.TIMEOFDAY.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.DATETIME =
function()
{
@@ -3497,6 +4302,26 @@ function(in_window)
in_window.org.pkijs.asn1.DATETIME.prototype = new in_window.org.pkijs.asn1.UTF8STRING();
in_window.org.pkijs.asn1.DATETIME.constructor = in_window.org.pkijs.asn1.DATETIME;
//**************************************************************************************
+ in_window.org.pkijs.asn1.DATETIME.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "DATETIME";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.DATETIME.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.DATETIME.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.DURATION =
function()
{
@@ -3506,6 +4331,26 @@ function(in_window)
in_window.org.pkijs.asn1.DURATION.prototype = new in_window.org.pkijs.asn1.UTF8STRING();
in_window.org.pkijs.asn1.DURATION.constructor = in_window.org.pkijs.asn1.DURATION;
//**************************************************************************************
+ in_window.org.pkijs.asn1.DURATION.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "DURATION";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.DURATION.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.DURATION.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
in_window.org.pkijs.asn1.TIME =
function()
{
@@ -3518,6 +4363,26 @@ function(in_window)
in_window.org.pkijs.asn1.TIME.prototype = new in_window.org.pkijs.asn1.UTF8STRING();
in_window.org.pkijs.asn1.TIME.constructor = in_window.org.pkijs.asn1.TIME;
//**************************************************************************************
+ in_window.org.pkijs.asn1.TIME.prototype.block_name =
+ function()
+ {
+ /// Aux function, need to get a block name. Need to have it here for inhiritence
+
+ return "TIME";
+ }
+ //**************************************************************************************
+ in_window.org.pkijs.asn1.TIME.prototype.toJSON =
+ function()
+ {
+ /// Convertion for the block to JSON object
+
+ var _object = in_window.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);
+
+ _object.block_name = in_window.org.pkijs.asn1.TIME.prototype.block_name.call(this);
+
+ return _object;
+ }
+ //**************************************************************************************
// #endregion
//**************************************************************************************
// #region Declaration of special ASN.1 schema type CHOICE
@@ -4274,5 +5139,16 @@ function(in_window)
//**************************************************************************************
// #endregion
//**************************************************************************************
+ // #region Major function converting JSON to ASN.1 objects
+ //**************************************************************************************
+ in_window.org.pkijs.fromJSON =
+ function(json)
+ {
+ /// Converting from JSON to ASN.1 objects
+ /// JSON string or object to convert to ASN.1 objects
+ }
+ //**************************************************************************************
+ // #endregion
+ //**************************************************************************************
}
)(typeof exports !== "undefined" ? exports : window);
diff --git a/org/pkijs/common.js b/org/pkijs/common.js
index 3ef6555..c69d99e 100644
--- a/org/pkijs/common.js
+++ b/org/pkijs/common.js
@@ -194,7 +194,7 @@ function(in_window)
for(var i = 0; i < int_buffer.length; i++)
{
var str = int_buffer[i].toString(16).toUpperCase();
- result = result + ((str.length === 1) ? " 0" : " ") + str;
+ result = result + ((str.length === 1) ? "0" : "") + str;
}
return result;