const UChar* unext(int32_t* resultLength, UErrorCode& status) { const UnicodeString* us = snext(status); if (us != NULL) { if (resultLength) { resultLength[0] = us->length(); } // TimeZone terminates the ID strings when it builds them return us->getBuffer(); } return NULL; }
/* Return the hash algorithm from a KSBA sig-val. SIGVAL is a canonical encoded S-expression. Return 0 if the hash algorithm is not encoded in SIG-VAL or it is not supported by libgcrypt. */ int hash_algo_from_sigval (const unsigned char *sigval) { const unsigned char *s = sigval; size_t n; int depth; char buffer[50]; if (!s || *s != '(') return 0; /* Invalid S-expression. */ s++; n = snext (&s); if (!n) return 0; /* Invalid S-expression. */ if (!smatch (&s, n, "sig-val")) return 0; /* Not a sig-val. */ if (*s != '(') return 0; /* Invalid S-expression. */ s++; /* Skip over the algo+parameter list. */ depth = 1; if (sskip (&s, &depth) || depth) return 0; /* Invalid S-expression. */ if (*s != '(') return 0; /* No futher list. */ /* Check whether this is (hash ALGO). */ s++; n = snext (&s); if (!n) return 0; /* Invalid S-expression. */ if (!smatch (&s, n, "hash")) return 0; /* Not a "hash" keyword. */ n = snext (&s); if (!n || n+1 >= sizeof (buffer)) return 0; /* Algorithm string is missing or too long. */ memcpy (buffer, s, n); buffer[n] = 0; return gcry_md_map_name (buffer); }
const UChar * StringEnumeration::unext(int32_t *resultLength, UErrorCode &status) { const UnicodeString *s=snext(status); if(U_SUCCESS(status) && s!=NULL) { unistr=*s; if(resultLength!=NULL) { *resultLength=unistr.length(); } return unistr.getTerminatedBuffer(); } return NULL; }
const char* next(int32_t* resultLength, UErrorCode& status) { // TODO: Later a subclass of StringEnumeration will be available // that implements next() and unext() in terms of snext(). // Inherit from that class when available and remove this method // (and its declaration). const UnicodeString* us = snext(status); int32_t newlen; if (us != NULL && ensureCapacity((newlen=us->length()) + 1)) { us->extract(0, INT32_MAX, (char*) _bufp, ""); if (resultLength) { resultLength[0] = newlen; } return (const char*)_bufp; } return NULL; }
const char * StringEnumeration::next(int32_t *resultLength, UErrorCode &status) { const UnicodeString *s=snext(status); if(U_SUCCESS(status) && s!=NULL) { unistr=*s; ensureCharsCapacity(unistr.length()+1, status); if(U_SUCCESS(status)) { if(resultLength!=NULL) { *resultLength=unistr.length(); } unistr.extract(0, INT32_MAX, chars, charsCapacity, US_INV); return chars; } } return NULL; }
/* Decrypt the the value given asn an S-expression in CIPHER using the key identified by SHADOW_INFO and return the plaintext in an allocated buffer in R_BUF. */ int divert_pkdecrypt (ctrl_t ctrl, const unsigned char *cipher, const unsigned char *shadow_info, char **r_buf, size_t *r_len) { int rc; char *kid; const unsigned char *s; size_t n; const unsigned char *ciphertext; size_t ciphertextlen; char *plaintext; size_t plaintextlen; s = cipher; if (*s != '(') return gpg_error (GPG_ERR_INV_SEXP); s++; n = snext (&s); if (!n) return gpg_error (GPG_ERR_INV_SEXP); if (!smatch (&s, n, "enc-val")) return gpg_error (GPG_ERR_UNKNOWN_SEXP); if (*s != '(') return gpg_error (GPG_ERR_UNKNOWN_SEXP); s++; n = snext (&s); if (!n) return gpg_error (GPG_ERR_INV_SEXP); if (!smatch (&s, n, "rsa")) return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM); if (*s != '(') return gpg_error (GPG_ERR_UNKNOWN_SEXP); s++; n = snext (&s); if (!n) return gpg_error (GPG_ERR_INV_SEXP); if (!smatch (&s, n, "a")) return gpg_error (GPG_ERR_UNKNOWN_SEXP); n = snext (&s); if (!n) return gpg_error (GPG_ERR_UNKNOWN_SEXP); ciphertext = s; ciphertextlen = n; rc = ask_for_card (ctrl, shadow_info, &kid); if (rc) return rc; rc = agent_card_pkdecrypt (ctrl, kid, getpin_cb, ctrl, ciphertext, ciphertextlen, &plaintext, &plaintextlen); if (!rc) { *r_buf = plaintext; *r_len = plaintextlen; } xfree (kid); return rc; }