Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
825532a4
Commit
825532a4
authored
26 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Obsolete.
Rev: lib/modules/Standards.pmod/ASN1.pmod/decode.pike:1.3(DEAD)
parent
f134265b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitattributes
+0
-1
0 additions, 1 deletion
.gitattributes
lib/modules/Standards.pmod/ASN1.pmod/decode.pike
+0
-117
0 additions, 117 deletions
lib/modules/Standards.pmod/ASN1.pmod/decode.pike
with
0 additions
and
118 deletions
.gitattributes
+
0
−
1
View file @
825532a4
...
@@ -70,7 +70,6 @@ testfont binary
...
@@ -70,7 +70,6 @@ testfont binary
/lib/modules/Sql.pmod/postgres.pike foreign_ident
/lib/modules/Sql.pmod/postgres.pike foreign_ident
/lib/modules/Sql.pmod/sql.pike foreign_ident
/lib/modules/Sql.pmod/sql.pike foreign_ident
/lib/modules/Sql.pmod/sql_result.pike foreign_ident
/lib/modules/Sql.pmod/sql_result.pike foreign_ident
/lib/modules/Standards.pmod/ASN1.pmod/decode.pike foreign_ident
/lib/modules/Yabu.pmod/module.pmod foreign_ident
/lib/modules/Yabu.pmod/module.pmod foreign_ident
/lib/modules/error.pmod foreign_ident
/lib/modules/error.pmod foreign_ident
/man/hilfe.1 foreign_ident
/man/hilfe.1 foreign_ident
...
...
This diff is collapsed.
Click to expand it.
lib/modules/Standards.pmod/ASN1.pmod/decode.pike
deleted
100644 → 0
+
0
−
117
View file @
f134265b
/* decode.pike
*
* Rudimentary support for decoding ASN.1 encoded data.
*
* $Id: decode.pike,v 1.2 1998/04/20 01:49:39 nisse Exp $
*/
/* BER/DER decoder
*
* Values are represented as arrays ({ tag, value }).
* Tag is either an integer tag number, or a string, in case
* the tag recognized.
*
* Values are strings, integers, or arrays */
inherit ADT.struct;
array get_asn1()
{
int|string tag = get_uint(1);
int len;
string contents;
mixed value;
#ifdef SSL3_DEBUG
werror(sprintf("decoding tag %x\n", tag));
#endif
if ( (tag & 0x1f) == 0x1f)
throw( ({ "high tag numbers is not supported\n", backtrace() }) );
int len = get_uint(1);
if (len & 0x80)
len = get_uint(len & 0x7f);
#ifdef SSL3_DEBUG
werror(sprintf("len : %d\n", len));
#endif
contents = get_fix_string(len);
#ifdef SSL3_DEBUG
werror(sprintf("contents: %O\n", contents));
#endif
value = contents; /* Default is no conversion */
if (tag & 0x20)
{
object seq = object_program(this_object())(contents);
value = ({ });
while(! seq->is_empty())
{
array elem = seq->get_asn1();
#ifdef SSL3_DEBUG
// werror(sprintf("elem: %O\n", elem));
#endif
value += ({ elem });
}
}
switch(tag & 0xdf)
{
case 1: /* Boolean */
if (strlen(contents) != 1)
throw( ({ "SSL.asn1: Invalid boolean value.\n", backtrace() }) );
tag = "BOOLEAN";
value = !!contents[0];
break;
case 2: /* Integer */
tag = "INTEGER";
value = Gmp.mpz(contents, 256);
if (contents[0] & 0x80) /* Negative */
value -= Gmp.pow(256, strlen(contents));
break;
case 3: /* Bit string */
tag = "BIT STRING";
break;
case 4: /* Octet string */
tag = "OCTET STRING";
break;
case 5: /* Null */
if (strlen(contents))
throw( ({ "SSL.asn1: Invalid NULL value.\n", backtrace() }) );
tag = "NULL";
value = 0;
break;
case 6: /* Object id */
{
tag = "Identifier";
if (contents[0] < 120)
value = ({ contents[0] / 40, contents[0] % 40 });
else
value = ({ 2, contents[0] - 80 });
int index = 1;
while(index < strlen(contents))
{
int id = 0;
do
{
id = id << 7 | (contents[index] & 0x7f);
} while(contents[index++] & 0x80);
value += ({ id });
}
break;
}
case 9: /* Real */
tag = "REAL";
break;
case 10: /* Enumerated */
tag = "ENUMERATED";
break;
case 16: /* Sequence */
tag = "SEQUENCE";
break;
case 17: /* Set */
tag = "SET";
break;
default: /* Keep numeric tag */
break;
}
return ({ tag, value });
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment