asn1util.pas - INT64 support in ASNEncInt and ASNItem.
git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@175 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
		
							
								
								
									
										22
									
								
								asn1util.pas
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								asn1util.pas
									
									
									
									
									
								
							| @@ -1,9 +1,9 @@ | ||||
| {==============================================================================| | ||||
| | Project : Ararat Synapse                                       | 001.004.004 | | ||||
| | Project : Ararat Synapse                                       | 002.000.000 | | ||||
| |==============================================================================| | ||||
| | Content: support for ASN.1 BER coding and decoding                           | | ||||
| |==============================================================================| | ||||
| | Copyright (c)1999-2003, Lukas Gebauer                                        | | ||||
| | Copyright (c)1999-2013, Lukas Gebauer                                        | | ||||
| | All rights reserved.                                                         | | ||||
| |                                                                              | | ||||
| | Redistribution and use in source and binary forms, with or without           | | ||||
| @@ -33,7 +33,7 @@ | ||||
| | DAMAGE.                                                                      | | ||||
| |==============================================================================| | ||||
| | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).| | ||||
| | Portions created by Lukas Gebauer are Copyright (c) 1999-2003                | | ||||
| | Portions created by Lukas Gebauer are Copyright (c) 1999-2013                | | ||||
| | Portions created by Hernan Sanchez are Copyright (c) 2000.                   | | ||||
| | All Rights Reserved.                                                         | | ||||
| |==============================================================================| | ||||
| @@ -103,7 +103,7 @@ function ASNEncLen(Len: Integer): AnsiString; | ||||
| function ASNDecLen(var Start: Integer; const Buffer: AnsiString): Integer; | ||||
|  | ||||
| {:Encodes a signed integer to ASN.1 binary} | ||||
| function ASNEncInt(Value: Integer): AnsiString; | ||||
| function ASNEncInt(Value: Int64): AnsiString; | ||||
|  | ||||
| {:Encodes unsigned integer into ASN.1 binary} | ||||
| function ASNEncUInt(Value: Integer): AnsiString; | ||||
| @@ -214,23 +214,28 @@ begin | ||||
| end; | ||||
|  | ||||
| {==============================================================================} | ||||
| function ASNEncInt(Value: Integer): AnsiString; | ||||
| function ASNEncInt(Value: Int64): AnsiString; | ||||
| var | ||||
|   x, y: Cardinal; | ||||
|   x: Int64; | ||||
|   y: byte; | ||||
|   neg: Boolean; | ||||
| begin | ||||
|   neg := Value < 0; | ||||
|   x := Abs(Value); | ||||
|   if neg then | ||||
|     x := not (x - 1); | ||||
|     x := x - 1; | ||||
|   Result := ''; | ||||
|   repeat | ||||
|     y := x mod 256; | ||||
|     x := x div 256; | ||||
|     if neg then | ||||
|       y := not y; | ||||
|     Result := AnsiChar(y) + Result; | ||||
|   until x = 0; | ||||
|   if (not neg) and (Result[1] > #$7F) then | ||||
|     Result := #0 + Result; | ||||
|   if (neg) and (Result[1] < #$80) then | ||||
|     Result := #$FF + Result; | ||||
| end; | ||||
|  | ||||
| {==============================================================================} | ||||
| @@ -265,7 +270,8 @@ function ASNItem(var Start: Integer; const Buffer: AnsiString; | ||||
| var | ||||
|   ASNType: Integer; | ||||
|   ASNSize: Integer; | ||||
|   y, n: Integer; | ||||
|   y: int64; | ||||
|   n: Integer; | ||||
|   x: byte; | ||||
|   s: AnsiString; | ||||
|   c: AnsiChar; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user