Moved eel and eapml under the contrib folder.
This commit is contained in:
29
contrib/ise_library/text/encryption/eel/der/array_der_sink.e
Normal file
29
contrib/ise_library/text/encryption/eel/der/array_der_sink.e
Normal file
@@ -0,0 +1,29 @@
|
||||
note
|
||||
description: "Summary description for {ARRAY_DER_SINK}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ARRAY_DER_SINK
|
||||
|
||||
inherit
|
||||
DER_OCTET_SINK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
make (target_a: ARRAY [NATURAL_8])
|
||||
do
|
||||
target := target_a
|
||||
end
|
||||
|
||||
sink (item: NATURAL_8)
|
||||
do
|
||||
target.force (item, target.upper + 1)
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
target: ARRAY [NATURAL_8]
|
||||
end
|
||||
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "Summary description for {ARRAY_DER_SOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ARRAY_DER_SOURCE
|
||||
|
||||
inherit
|
||||
DER_OCTET_SOURCE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
make (source_a: ARRAY [NATURAL_8])
|
||||
do
|
||||
source := source_a
|
||||
end
|
||||
|
||||
feature
|
||||
has_item: BOOLEAN
|
||||
do
|
||||
result := source.valid_index (current_index)
|
||||
end
|
||||
|
||||
item: NATURAL_8
|
||||
do
|
||||
result := source [current_index]
|
||||
end
|
||||
|
||||
process
|
||||
do
|
||||
current_index := current_index + 1
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
current_index: INTEGER_32
|
||||
source: ARRAY [NATURAL_8]
|
||||
|
||||
invariant
|
||||
source.valid_index (current_index) or current_index = source.upper + 1
|
||||
end
|
||||
18
contrib/ise_library/text/encryption/eel/der/der_encodable.e
Normal file
18
contrib/ise_library/text/encryption/eel/der/der_encodable.e
Normal file
@@ -0,0 +1,18 @@
|
||||
note
|
||||
description: "An object that is DER encodable"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "I think the terror most people are concerned with is the IRS. - Malcolm Forbes, when asked if he was afraid of terrorism"
|
||||
|
||||
deferred class
|
||||
DER_ENCODABLE
|
||||
|
||||
inherit
|
||||
DER_FACILITIES
|
||||
|
||||
feature
|
||||
der_encode (target: DER_OCTET_SINK)
|
||||
deferred
|
||||
end
|
||||
end
|
||||
24
contrib/ise_library/text/encryption/eel/der/der_encoding.e
Normal file
24
contrib/ise_library/text/encryption/eel/der/der_encoding.e
Normal file
@@ -0,0 +1,24 @@
|
||||
note
|
||||
description: "Summary description for {DER_ENCODING}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DER_ENCODING
|
||||
|
||||
inherit
|
||||
DEVELOPER_EXCEPTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
make (reason_a: STRING)
|
||||
do
|
||||
reason := reason_a
|
||||
end
|
||||
|
||||
feature
|
||||
reason: STRING
|
||||
end
|
||||
196
contrib/ise_library/text/encryption/eel/der/der_facilities.e
Normal file
196
contrib/ise_library/text/encryption/eel/der/der_facilities.e
Normal file
@@ -0,0 +1,196 @@
|
||||
note
|
||||
description: "Summary description for {DER_FACILITIES}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
DER_FACILITIES
|
||||
|
||||
inherit
|
||||
DER_UNIVERSAL_CLASS_TAG
|
||||
|
||||
feature
|
||||
identifier_class (in: NATURAL_8): NATURAL_8
|
||||
do
|
||||
result := in & 0xc0
|
||||
end
|
||||
|
||||
identifier_universal: NATURAL_8 = 0x00
|
||||
identifier_application: NATURAL_8 = 0xa0
|
||||
identifier_context_specific: NATURAL_8 = 0xb0
|
||||
identifier_private: NATURAL_8 = 0xc0
|
||||
identifier_constructed: NATURAL_8 = 0x20
|
||||
|
||||
identifier_primitive (in: NATURAL_8): BOOLEAN
|
||||
do
|
||||
result := (in & identifier_constructed) = 0
|
||||
end
|
||||
|
||||
identifier_tag (in: NATURAL_8): NATURAL_8
|
||||
do
|
||||
result := in & 0x1f
|
||||
end
|
||||
|
||||
identifier_high_number (in: NATURAL_8): BOOLEAN
|
||||
do
|
||||
result := identifier_tag (in) = 0x1f
|
||||
end
|
||||
|
||||
identifier_last (in: NATURAL_8): BOOLEAN
|
||||
do
|
||||
result := (in & 0x80) = 0
|
||||
end
|
||||
|
||||
encode_boolean (target: DER_OCTET_SINK in: BOOLEAN)
|
||||
do
|
||||
target.sink (boolean)
|
||||
target.sink (0x01)
|
||||
if
|
||||
in
|
||||
then
|
||||
target.sink (0xff)
|
||||
else
|
||||
target.sink (0x00)
|
||||
end
|
||||
end
|
||||
|
||||
definite_length (target: DER_OCTET_SINK length: INTEGER_32)
|
||||
require
|
||||
length >= 0
|
||||
do
|
||||
if
|
||||
length <= 127
|
||||
then
|
||||
definite_short_length (target, length)
|
||||
else
|
||||
definite_long_length (target, length)
|
||||
end
|
||||
end
|
||||
|
||||
definite_short_length (target: DER_OCTET_SINK length: INTEGER_32)
|
||||
require
|
||||
length >= 0
|
||||
length <= 127
|
||||
do
|
||||
target.sink (length.to_natural_8)
|
||||
end
|
||||
|
||||
definite_long_length (target: DER_OCTET_SINK length: INTEGER_32)
|
||||
require
|
||||
length >= 0
|
||||
do
|
||||
target.sink (0x84)
|
||||
target.sink ((length |>> 24).to_natural_8)
|
||||
target.sink ((length |>> 16).to_natural_8)
|
||||
target.sink ((length |>> 8).to_natural_8)
|
||||
target.sink ((length |>> 0).to_natural_8)
|
||||
end
|
||||
|
||||
|
||||
decode_length (source: DER_OCTET_SOURCE): INTEGER_X
|
||||
do
|
||||
if
|
||||
source.item <= 127
|
||||
then
|
||||
result := decode_short_length (source)
|
||||
else
|
||||
result := decode_long_length (source)
|
||||
end
|
||||
end
|
||||
|
||||
decode_short_length (source: DER_OCTET_SOURCE): INTEGER_X
|
||||
do
|
||||
create result.make_from_integer (source.item.to_integer_32)
|
||||
source.process
|
||||
end
|
||||
|
||||
decode_long_length (source: DER_OCTET_SOURCE): INTEGER_X
|
||||
local
|
||||
length_count: INTEGER_32
|
||||
current_byte: INTEGER_32
|
||||
current_bit: INTEGER_32
|
||||
do
|
||||
length_count := (source.item & 0x7f).to_integer_32
|
||||
if
|
||||
length_count = 127
|
||||
then
|
||||
(create {DER_ENCODING}.make ("Unacceptable long form length encoding")).raise
|
||||
end
|
||||
create result.default_create
|
||||
from
|
||||
current_byte := length_count
|
||||
until
|
||||
current_byte = 0
|
||||
loop
|
||||
from
|
||||
current_bit := 8
|
||||
until
|
||||
current_bit = 0
|
||||
loop
|
||||
if
|
||||
source.item.bit_test (current_bit - 1)
|
||||
then
|
||||
Result := Result.set_bit_value (True, (current_byte - 1) * 8 + (current_bit - 1))
|
||||
end
|
||||
current_bit := current_bit - 1
|
||||
variant
|
||||
current_bit + 1
|
||||
end
|
||||
source.process
|
||||
current_byte := current_byte - 1
|
||||
variant
|
||||
current_byte + 1
|
||||
end
|
||||
end
|
||||
|
||||
encode_integer (target: DER_OCTET_SINK in: INTEGER_X)
|
||||
local
|
||||
bytes: INTEGER_32
|
||||
counter: INTEGER_32
|
||||
do
|
||||
if
|
||||
in.is_negative
|
||||
then
|
||||
bytes := (in + in.one).bytes
|
||||
else
|
||||
bytes := in.bytes
|
||||
end
|
||||
target.sink (integer)
|
||||
definite_length (target, bytes)
|
||||
from
|
||||
counter := bytes
|
||||
until
|
||||
counter = 0
|
||||
loop
|
||||
target.sink (byte_at (in, counter))
|
||||
counter := counter - 1
|
||||
variant
|
||||
counter + 1
|
||||
end
|
||||
end
|
||||
|
||||
byte_at (in: INTEGER_X index: INTEGER_32): NATURAL_8
|
||||
require
|
||||
index >= 0
|
||||
index <= in.bytes
|
||||
local
|
||||
current_bit: INTEGER_32
|
||||
do
|
||||
from
|
||||
current_bit := 8
|
||||
until
|
||||
current_bit = 0
|
||||
loop
|
||||
result := result |<< 1
|
||||
if
|
||||
in.bit_test ((index - 1) * 8 + (current_bit - 1))
|
||||
then
|
||||
result := result | 0x01
|
||||
end
|
||||
current_bit := current_bit - 1
|
||||
variant
|
||||
current_bit + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
15
contrib/ise_library/text/encryption/eel/der/der_octet_sink.e
Normal file
15
contrib/ise_library/text/encryption/eel/der/der_octet_sink.e
Normal file
@@ -0,0 +1,15 @@
|
||||
note
|
||||
description: "A sink for DER octets"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "The illegal we do immediately. The unconstitutional takes a bit longer. - Henry Kissinger"
|
||||
|
||||
deferred class
|
||||
DER_OCTET_SINK
|
||||
|
||||
feature
|
||||
sink (item: NATURAL_8)
|
||||
deferred
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
note
|
||||
description: "DER octet source"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Our forefathers made one mistake. What they should have fought for was representation without taxation. - Fletcher Knebel, historian"
|
||||
|
||||
deferred class
|
||||
DER_OCTET_SOURCE
|
||||
|
||||
feature
|
||||
has_item: BOOLEAN
|
||||
deferred
|
||||
end
|
||||
|
||||
item: NATURAL_8
|
||||
require
|
||||
has_item
|
||||
deferred
|
||||
end
|
||||
|
||||
process
|
||||
require
|
||||
has_item
|
||||
deferred
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
note
|
||||
description: "ASN.1 universal class tag assignments X.680 8.4"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "The usual road to slavery is that first they take away your guns, then they take away your property, then last of all they tell you to shut up and say you are enjoying it. - James A. Donald"
|
||||
|
||||
deferred class
|
||||
DER_UNIVERSAL_CLASS_TAG
|
||||
|
||||
feature
|
||||
reserved: NATURAL_8 = 0x0
|
||||
boolean: NATURAL_8 = 0x1
|
||||
integer: NATURAL_8 = 0x2
|
||||
bit_string: NATURAL_8 = 0x3
|
||||
octet_string: NATURAL_8 = 0x4
|
||||
null: NATURAL_8 = 0x5
|
||||
object_identifier: NATURAL_8 = 0x6
|
||||
object_descriptor: NATURAL_8 = 0x7
|
||||
external_type: NATURAL_8 = 0x8
|
||||
real: NATURAL_8 = 0x9
|
||||
enumerated: NATURAL_8 = 0xa
|
||||
embedded_pdv: NATURAL_8 = 0xb
|
||||
utf8_string: NATURAL_8 = 0xc
|
||||
relative_object_identifier: NATURAL_8 = 0xd
|
||||
sequence: NATURAL_8 = 0x10
|
||||
set: NATURAL_8 = 0x11
|
||||
universal_time: NATURAL_8 = 0x17
|
||||
generalized_time: NATURAL_8 = 0x18
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user