Commit Graph

104 Commits

Author SHA1 Message Date
ludovic.rousseau 9906e5af66 Remove dead code
asn1.c:1321:3: warning: Value stored to 'r' is never read
                r = 0;
                ^   ~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5155 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 21:03:28 +00:00
vtarasov 71bfc87282 asn1: spelling of the debug messages
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5090 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-13 15:06:12 +00:00
vtarasov 66412d6e53 asn1: accept long tag ...
According to X.690-0207 ch.8.1.2.4


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5088 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-13 13:59:22 +00:00
vtarasov fa9ed3add0 asn1: invalid detection of AID presence in ASN1 path data
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5078 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-10 10:44:52 +00:00
vtarasov 40cb9c99b8 asn1: decode 'extendedPath'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5077 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-09 17:25:09 +00:00
vtarasov 65cd456256 opensc-explorer: print raw content of 'CONTEXT' tag
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5058 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 15:47:58 +00:00
vtarasov e600a1e0ac opensc-explorer: in 'asn1' command print raw content of the ASN1_APPLICATION data
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5055 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 09:00:39 +00:00
vtarasov 0761a61a65 libopensc: use 'struct sc_aid' instead of 'u8 *aid, size_t aid_len'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5048 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-05 15:42:36 +00:00
vtarasov 4b5bc9900c libopensc: asn1: allow empty path
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5022 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-02 14:14:24 +00:00
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
viktor.tarasov 006c30c2e0 #245: pkcs15 asn1: 'subjectName' in 'commonPrivateKeyAttributes' is optional
thanks to Jean-Michel


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4518 c6295689-39f2-0310-b995-f0e70906c6a9
2010-07-08 08:09:46 +00:00
viktor.tarasov 3a3c41a6db pkcs15: encode/decode 'AccessControlRules' in 'CommonObjectAttributes'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4515 c6295689-39f2-0310-b995-f0e70906c6a9
2010-07-06 09:09:04 +00:00
viktor.tarasov b78d7630e7 pkcs15: encode/decode 'subjectName' in 'CommonPrivateKeyAttributes'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4512 c6295689-39f2-0310-b995-f0e70906c6a9
2010-07-05 13:29:10 +00:00
martin 68f12c881d Fix a segfault leftover from r4118
Thanks to Andre Zepezauer for the report and patch.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4391 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-31 16:49:55 +00:00
ludovic.rousseau 0c77a52f37 Remove 2 ugly casts and fix warnings
asn1.c: In function ‘asn1_decode_entry’:
asn1.c:979: warning: dereferencing type-punned pointer will break strict-aliasing rules
asn1.c: In function ‘asn1_encode_entry’:
asn1.c:1263: warning: dereferencing type-punned pointer will break strict-aliasing rules


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4207 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-02 13:12:53 +00:00
viktor.tarasov f75f539a6f libopensc: export 'sc_asn1_encode_object_id'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4142 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-22 14:14:51 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
viktor.tarasov 935b0740e4 libopensc: remove not used function
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4006 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-09 13:53:27 +00:00
aj f0484968a9 merge changes 0.11.11 -> 0.11.12
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3899 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-18 13:33:03 +00:00
martin d672fde449 Remove sc_error and sc_ctx_suppress_errors_* in favor of sc_debug/fprintf
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3721 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:46:59 +00:00
alonbl c862f88ce7 SIGSEGV print_tags_recursive - fix
Patch opensc-0.11.4.trunk-r3502-fix-segv_print_tags_asn1.diff (for trunk
trunk revision 3502) is draft.


Example 1 (SIGSEGV):

OpenSC Explorer version 0.11.4-svn
OpenSC [3F00]> cd ff00
OpenSC [3F00/FF00]> asn1 0001
Printing tags for buffer of length 512
[Switching to Thread -1211906368 (LWP 25131)]

By Aktiv Co. Aleksey Samsonov



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3504 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-29 06:11:34 +00:00
ludovic.rousseau 9740726f16 sc_asn1_decode_integer/asn1_encode_integer: correctly manage negative
numbers and some positive numbers like 128


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3401 c6295689-39f2-0310-b995-f0e70906c6a9
2008-02-29 15:37:46 +00:00
aj d59917cd21 asn1_decode_entry() allocates (objlen - 1) bytes for SC_ASN1_UTF8STRING
types with SC_ASN1_ALLOC flag, then calls the sc_asn1_decode_utf8string()
function which then fails with BUFFER TOO SMALL cause it wants to end the
string with an extra NULL.

allocation size was supposed to be objlen + 1.

Patch by Gürer Özen


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3225 c6295689-39f2-0310-b995-f0e70906c6a9
2007-07-20 12:30:59 +00:00
aj b3ad2f9dd2 convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3084 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:31:17 +00:00
nils 01f72933af add support to parse the seInfo TokenInfo entry, improve aid support in opensc-explorer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3045 c6295689-39f2-0310-b995-f0e70906c6a9
2006-10-30 18:51:48 +00:00
nils fdd0baa633 bugfix: return error if OID is invalid
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2986 c6295689-39f2-0310-b995-f0e70906c6a9
2006-07-11 22:25:45 +00:00
aj 7ffd0f1d79 remove dead code.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2902 c6295689-39f2-0310-b995-f0e70906c6a9
2006-04-26 10:01:52 +00:00
nils 8494d9cfde add support for two byte tags in sc_asn1_find_tag() + normalize return value
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2839 c6295689-39f2-0310-b995-f0e70906c6a9
2006-02-12 18:29:52 +00:00
nils e8c05ca648 use more opensc specific names for ASN.1 tags to avoid name conflicts
with other ASN.1 libraries


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2815 c6295689-39f2-0310-b995-f0e70906c6a9
2006-01-20 20:52:36 +00:00
nils 59cae4140b fix compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2585 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-12 21:09:12 +00:00
nils 9ca1bc2a09 remove unused internal function
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2534 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-04 08:57:17 +00:00
nils eec0e22b03 de-/encode printable strings as well
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2514 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-24 08:00:44 +00:00
nils f8d6634339 set obj to NULL to avoid double free in case of an error
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2479 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-10 21:00:52 +00:00
nils 45a9d05830 cleanup, mostly signed/unsigned issues
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2469 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-08 10:22:14 +00:00
nils ed3ba0231e improve generalizedTime support + more cleanup
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2464 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-05 07:28:20 +00:00
nils d67389dfd6 bools are int; pointed out by William Wanders <william@wanders.org>
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2288 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-30 16:40:01 +00:00
pisi a1ffc6b72e Space cleanups
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2234 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-09 10:47:01 +00:00
bert 2d97002824 API fixup: use defined type instead of struct for exposed structs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2232 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-08 20:59:35 +00:00
sth 90e967d042 Fix: stop parsing at the end of the file, not when finding padding bytes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2103 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-27 21:35:23 +00:00
nils a82a40e977 some cleanup + improved error checking
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2051 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-03 17:20:17 +00:00
nils ebf6c8ecfa fix type, found by T.Fujita <fujita@ouk.jp>
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2043 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-23 10:49:10 +00:00
nils 9953d0b21d fix some compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1905 c6295689-39f2-0310-b995-f0e70906c6a9
2004-09-20 09:47:35 +00:00
nils 0464df9235 fix ASN1 NULL handling and avoid malloc(0)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1862 c6295689-39f2-0310-b995-f0e70906c6a9
2004-07-23 16:11:23 +00:00
nils f044157553 fix incorrect use of realloc (x = realloc(x, y) doesn't free
the x in case of a failure)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1775 c6295689-39f2-0310-b995-f0e70906c6a9
2004-04-21 18:10:58 +00:00
aet 7d3fc55736 - Minor build and C++ warning fixes
- pkcs15init: Use u8 for pin variable
  declarations like libopensc does


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1686 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-18 21:37:34 +00:00
okir 8ed95baff1 - Updated previous patch
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1675 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-16 11:04:01 +00:00
sth 6b66973692 Prevent running off the end of the buffer if the asn.1 is invalid (Chaskiel G.)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1674 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-16 08:01:36 +00:00
okir 3c89fc8edb - improved support for CHOICE
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1642 c6295689-39f2-0310-b995-f0e70906c6a9
2003-11-26 15:35:17 +00:00
okir 12386d65c9 - When encoding a path, either encode _neither_ index/count, or both.
- Added new functions sc_der_copy, sc_der_clear to handle DER blobs
- Somewhat improved debug output


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1609 c6295689-39f2-0310-b995-f0e70906c6a9
2003-11-19 20:22:52 +00:00