Changed SILC_ASN1_OCTET_STRING to plain binary data.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 23 Jan 2007 14:52:52 +0000 (14:52 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 23 Jan 2007 14:52:52 +0000 (14:52 +0000)
lib/silcasn1/silcasn1.h
lib/silcasn1/silcasn1_decode.c
lib/silcasn1/silcasn1_encode.c
lib/silcasn1/tests/test_silcasn1.c

index 51a7015c96fb33675a85a871657b3d789c8648a1..df5bde14dab3319be604476d40de1647c15985f5 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2003 - 2006 Pekka Riikonen
+  Copyright (C) 2003 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -666,7 +666,7 @@ SilcBool silc_asn1_decode(SilcAsn1 asn1, SilcBuffer src, ...);
  *
  * DESCRIPTION
  *
- *    Macro used to encode or decode boolean value.  Type boolean type
+ *    Macro used to encode or decode boolean value.  The boolean type
  *    is SilcBool.
  *
  *    The `opts' is SilcAsn1Options.  The `tag' is a tag number.
@@ -829,16 +829,11 @@ SilcBool silc_asn1_decode(SilcAsn1 asn1, SilcBuffer src, ...);
  * DESCRIPTION
  *
  *    Macro used to encode or decode octet string.  The string type is
- *    unsigned char and string length SilcUInt32.
+ *    unsigned char and string length SilcUInt32.  Octet string is
+ *    considered to be 8-bit unsigned binary data.
  *
  *    The `opts' is SilcAsn1Options.  The `tag' is a tag number.
  *
- * NOTES
- *
- *    The string must be in UTF-8 encoding when encoding.  The decoded
- *    string will be in UTF-8 encoding.  The actual data is encoded to
- *    or decoded from 8-bit ASCII.
- *
  ***/
 #define SILC_ASN1_OCTET_STRING(x, xl) SILC_ASN1_U2(OCTET_STRING, x, xl)
 #define SILC_ASN1_OCTET_STRING_T(o, t, x, xl) SILC_ASN1_T2(OCTET_STRING, o, t, x, xl)
index 911515b2b88ae472c2ba7d5ac2d26cc4ad1e0d05..ad5fe79e17ea39feef43195e6e8010a199c099d7 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2003 - 2006 Pekka Riikonen
+  Copyright (C) 2003 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -665,9 +665,10 @@ silc_asn1_decoder(SilcAsn1 asn1, SilcStack stack1, SilcAsn1Tag type,
 
       case SILC_ASN1_TAG_OCTET_STRING:
        {
-         /* Octet string.  We take it as 8-bit ASCII */
+         /* Octet string.  Take data as is. */
          SILC_ASN1_VAD_UCHAR(asn1, opts, unsigned char, s, s_len);
-         SILC_ASN1_DECODE_STRING(SILC_STRING_ASCII, s, s_len);
+         *s = silc_smemdup(stack1, rdata, rdata_len);
+         *s_len = rdata_len;
          break;
        }
 
index 0245185fc00686e7c2b81ec4d9a1c794af796f17..f4937390e76de8fd575eb91d133ae20550cc1370 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2003 - 2006 Pekka Riikonen
+  Copyright (C) 2003 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -555,8 +555,17 @@ silc_asn1_encoder(SilcAsn1 asn1, SilcStack stack1, SilcStack stack2,
 
     case SILC_ASN1_TAG_OCTET_STRING:
       {
-       /* Octet string.  We put it in as 8-bit ASCII */
-       SILC_ASN1_ENCODE_STRING(SILC_STRING_ASCII);
+       /* Octet string.  Put data as is. */
+       unsigned char *d = va_arg(asn1->ap, unsigned char *);
+       SilcUInt32 d_len = va_arg(asn1->ap, SilcUInt32);
+
+       len = silc_ber_encoded_len(tag, d_len, indef);
+       dest = silc_buffer_srealloc_size(stack1, dest,
+                                        silc_buffer_truelen(dest) + len);
+       ret = silc_ber_encode(dest, ber_class, SILC_BER_ENC_PRIMITIVE,
+                             tag, d, d_len, indef);
+       if (!ret)
+         goto fail;
        break;
       }
 
index 2f2ec76caefe2b9c08b7612e8238170ce1eb6661..74bd8c807f142bdb34d1c1c4fc3c8c62f237c6e1 100644 (file)
@@ -742,10 +742,13 @@ int main(int argc, char **argv)
   SILC_LOG_DEBUG(("Decoding success"));
   printf("\n");
 
-
-#endif
+#endif /* 1 */
   silc_asn1_free(asn1);
 
+  success = TRUE;
  out:
-  exit(success);
+  SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+  fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+
+  return success;
 }