private void ProcessTAG(ASN1TAG inputTag) { if (inputTag.IsExplicit()) { // TODO - sfiksaj ovo. /* ako je TAG explicit - stripaj omotac oko DER-a... */ /* ako je IMPLICIT - ignoriraj..., ostalo ne bi trebalo biti vazno... */ SimpleDER der = valueOctets.Pop() as SimpleDER; SimpleDER unwrappedDER = new SimpleDER(der.GetValueOctets()); PushDER(unwrappedDER); // sad nastavi dalje - sve dok ne dodjemo do simple taga... ProcessTAG(((EXPLICITTag)inputTag).underTag); } if (inputTag.IsImplicit()) { /// Go to the next step... ProcessTAG(((IMPLICITTag)inputTag).underTag); } }
public void Test_SimpleDER() { byte[] test1 = new byte[]{0x1, 0x2, 0x3, 0x4}; byte[] test2 = new byte[]{0x1, 0x82, 0x0f, 0x0f, 0x1}; byte[] test3 = new byte[]{0x7f, 0x83, 0x01, 0x2, 0x5, 0x5}; byte[] test4 = new byte[]{0x7f, 0x83, 0x81, 0x2, 0x82, 0x1, 0x2, 0x7 /* ... */}; SimpleDER der = new SimpleDER(test1); der = new SimpleDER(test2); der = new SimpleDER(test3); der = new SimpleDER(test4); }
public void Test_DERDecoder() { SimpleDER der = new SimpleDER(new byte[]{0x01, 0x01, 0xff}); DERPrettyPrinter.Print(der.GetAllOctets()); BOOLEAN_type bool_t = new BOOLEAN_type(); DERDecoder decoder = new DERDecoder(); decoder.Init(der); decoder.Visit(bool_t); BOOLEAN decodedObject = decoder.ShowResult() as BOOLEAN; Console.WriteLine(decodedObject.boolValue.ToString()); }
private void PushDER(SimpleDER simpleDER) { valueOctets.Push(simpleDER); }
public void Init(SimpleDER simpleDER) { PushDER(simpleDER); }
private void ProcessTheseTwo(SimpleDER der, ExperimentalType eType) { PushDER(der); Visit(eType); }
private void SEQUENCE_Process_DERs(SEQUENCE inst, SimpleDER[] ders) { /* process DERs according to the SEQUENCE instance */ int i=0,j=0; for ( ; i < ders.Length; i++, j++) { SimpleDER der = ders[i]; ComponentTypeInfo currentTI = inst.TypeInfos[j]; try { while (!der.Match(currentTI.Type.TAG)) { if (currentTI.DefaultValue != null) { PushInstance(currentTI.DefaultValue); /* No need for visiting.. */ } else if (currentTI.isOptional) { /* this is a marker for later initialization * of parent SEQUENCE instance. */ Push_MISSING_OPTIONAL_INSTANCE(); } else { throw new SEQUENCEComponentMismatchException("SEQUENCE Components mismatch!"); } currentTI = inst.TypeInfos[++j]; } } catch (IndexOutOfRangeException) { throw new SEQUENCEComponentMismatchException("SEQUENCE Components mismatch at DER:!"+i.ToString()); } ProcessTheseTwo(der, currentTI.Type); } }