s4:heimdal: import lorikeet-heimdal-201001120029 (commit a5e675fed7c5db8a7370b77ed0bf...
[samba.git] / source4 / heimdal / lib / asn1 / der_length.c
index 5ea3a848455f0ee5747886482f8eb2861f9da02f..688e6ba8171ef76b8951d5b9d2d0a92ba4963412 100644 (file)
@@ -3,6 +3,8 @@
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
+ * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -112,6 +114,20 @@ der_length_len (size_t len)
     }
 }
 
+size_t
+der_length_tag(unsigned int tag)
+{
+    size_t len = 0;
+
+    if(tag <= 30)
+       return 1;
+    while(tag) {
+       tag /= 128;
+       len++;
+    }
+    return len + 1;
+}
+
 size_t
 der_length_integer (const int *data)
 {