http://code.google.com/p/caffeine-hx/source/detail?r=657
Modified:
/trunk/ext3/chx/formats/der/DER.hx
/trunk/ext3/chx/formats/der/ExtractedBytes.hx
/trunk/ext3/chx/formats/der/IAsn1Type.hx
/trunk/ext3/chx/formats/der/OctetString.hx
/trunk/ext3/chx/formats/der/PEM.hx
/trunk/ext3/chx/formats/der/Sequence.hx
/trunk/ext3/chx/formats/der/UTCTime.hx
=======================================
--- /trunk/ext3/chx/formats/der/DER.hx Mon Apr 11 20:26:42 2011
+++ /trunk/ext3/chx/formats/der/DER.hx Sun Feb 12 19:53:32 2012
@@ -342,7 +342,6 @@
d.writeByte(len);
}
d.writeBytes(data,0,data.length);
- //d.position=0;
return d.getBytes();
}
}
=======================================
--- /trunk/ext3/chx/formats/der/ExtractedBytes.hx Mon Apr 11 20:26:42 2011
+++ /trunk/ext3/chx/formats/der/ExtractedBytes.hx Sun Feb 12 19:53:32 2012
@@ -62,7 +62,7 @@
}
public function toString():String {
- return buf.toHex(" ").toUpperCase();
+ return buf.toHex(" ");
}
public function toDER():Bytes {
=======================================
--- /trunk/ext3/chx/formats/der/IAsn1Type.hx Mon Apr 11 20:26:42 2011
+++ /trunk/ext3/chx/formats/der/IAsn1Type.hx Sun Feb 12 19:53:32 2012
@@ -40,4 +40,5 @@
function getType():Int;
//function getLength():Int;
function toDER() : Bytes;
-}
+ function toString() : String;
+}
=======================================
--- /trunk/ext3/chx/formats/der/OctetString.hx Mon Apr 11 20:26:42 2011
+++ /trunk/ext3/chx/formats/der/OctetString.hx Sun Feb 12 19:53:32 2012
@@ -52,7 +52,7 @@
}
override public function toString() : String {
- return "OctetString["+toHex().toUpperCase()+"]";
+ return toHex().toUpperCase();
}
}
=======================================
--- /trunk/ext3/chx/formats/der/PEM.hx Mon Apr 11 20:26:42 2011
+++ /trunk/ext3/chx/formats/der/PEM.hx Sun Feb 12 19:53:32 2012
@@ -30,6 +30,7 @@
*/
/**
* PEM
+ * @see
http://etutorials.org/Programming/secure+programming/Chapter+7.+Public+Key+Cryptography/7.17+Representing+Keys+and+Certificates+in+Plaintext+PEM+Encoding/
*/
package chx.formats.der;
import chx.crypt.RSA;
=======================================
--- /trunk/ext3/chx/formats/der/Sequence.hx Mon Apr 11 21:43:04 2011
+++ /trunk/ext3/chx/formats/der/Sequence.hx Sun Feb 12 19:53:32 2012
@@ -125,4 +125,24 @@
}
return null;
}
-}
+
+ public function findAttributeValues(oid:String):Array<IAsn1Type> {
+ var rv : Array<IAsn1Type> = new Array();
+ for(set in this) {
+ if ( Std.is(set, Set) ) {
+ var child:IAsn1Type = cast(set, Set).get(0);
+ if ( Std.is(child, Sequence)) {
+ var sc:Sequence = cast child;
+ var tmp:IAsn1Type = sc.get(0);
+ if ( Std.is(tmp, ObjectIdentifier)) {
+ var id:ObjectIdentifier = cast tmp;
+ if (id.toString()==oid) {
+ rv.push(sc.get(1));
+ }
+ }
+ }
+ }
+ }
+ return rv;
+ }
+}
=======================================
--- /trunk/ext3/chx/formats/der/UTCTime.hx Mon Apr 11 20:26:42 2011
+++ /trunk/ext3/chx/formats/der/UTCTime.hx Sun Feb 12 19:53:32 2012
@@ -41,8 +41,9 @@
public static inline var TYPE : Int = 0x17;
public var date:Date;
- public function new()
- {
+ public function new(d:Date = null)
+ {
+ this.date = d;
}
public function getType():Int
@@ -54,6 +55,9 @@
return date;
}
+ /**
+ * @param str YYMMDDHHmmss
+ **/
public function setUTCTime(str:String):Void {
var year:Int = Std.parseInt(str.substr(0, 2));
if (year<50) {
@@ -65,13 +69,14 @@
var day:Int = Std.parseInt(str.substr(4,2));
var hour:Int = Std.parseInt(str.substr(6,2));
var minute:Int = Std.parseInt(str.substr(8,2));
- // TODO: this could be off by up to a day. parse the rest. someday.
- date = new Date(year, month-1, day, hour, minute, 0);
+ var second:Int = (str.length >= 12) ? Std.parseInt(str.substr(10,2)) : 0;
+ // TODO: this could be off by up to a day compared to wall time.
+ date = new Date(year, month-1, day, hour, minute, second);
}
public function toString():String {
- return "UTCTime["+date+"]";
+ return date != null ? date.toString() : "unknown";
}
/**