int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
{
    char *v;
    int gmt = 0;
    int i;
    int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
    char *f = NULL;
    int f_len = 0;
    i = tm->length;
    v = (char *)tm->data;
    if (i < 12)
        goto err;
    if (v[i - 1] == 'Z')
        gmt = 1;
    for (i = 0; i < 12; i++)
        if ((v[i] > '9') || (v[i] < '0'))
            goto err;
    y = (v[0] - '0') * 1000 + (v[1] - '0') * 100
        + (v[2] - '0') * 10 + (v[3] - '0');
    M = (v[4] - '0') * 10 + (v[5] - '0');
    if ((M > 12) || (M < 1))
        goto err;
    d = (v[6] - '0') * 10 + (v[7] - '0');
    h = (v[8] - '0') * 10 + (v[9] - '0');
    m = (v[10] - '0') * 10 + (v[11] - '0');
    if (tm->length >= 14 &&
        (v[12] >= '0') && (v[12] <= '9') &&
        (v[13] >= '0') && (v[13] <= '9')) {
        s = (v[12] - '0') * 10 + (v[13] - '0');
        if (tm->length >= 15 && v[14] == '.') {
            int l = tm->length;
            f = &v[14];
            f_len = 1;
            while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
                ++f_len;
        }
    }
    if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
                   mon[M - 1], d, h, m, s, f_len, f, y,
                   (gmt) ? " GMT" : "") <= 0)
        return (0);
    else
        return (1);
 err:
    BIO_write(bp, "Bad time value", 14);
    return (0);
}
['int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags)\n{\n    int i, ret = 0;\n    long l;\n    OCSP_CERTID *cid = NULL;\n    OCSP_BASICRESP *br = NULL;\n    OCSP_RESPID *rid = NULL;\n    OCSP_RESPDATA *rd = NULL;\n    OCSP_CERTSTATUS *cst = NULL;\n    OCSP_REVOKEDINFO *rev = NULL;\n    OCSP_SINGLERESP *single = NULL;\n    OCSP_RESPBYTES *rb = o->responseBytes;\n    if (BIO_puts(bp, "OCSP Response Data:\\n") <= 0)\n        goto err;\n    l = ASN1_ENUMERATED_get(o->responseStatus);\n    if (BIO_printf(bp, "    OCSP Response Status: %s (0x%lx)\\n",\n                   OCSP_response_status_str(l), l) <= 0)\n        goto err;\n    if (rb == NULL)\n        return 1;\n    if (BIO_puts(bp, "    Response Type: ") <= 0)\n        goto err;\n    if (i2a_ASN1_OBJECT(bp, rb->responseType) <= 0)\n        goto err;\n    if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) {\n        BIO_puts(bp, " (unknown response type)\\n");\n        return 1;\n    }\n    i = ASN1_STRING_length(rb->response);\n    if (!(br = OCSP_response_get1_basic(o)))\n        goto err;\n    rd = br->tbsResponseData;\n    l = ASN1_INTEGER_get(rd->version);\n    if (BIO_printf(bp, "\\n    Version: %lu (0x%lx)\\n", l + 1, l) <= 0)\n        goto err;\n    if (BIO_puts(bp, "    Responder Id: ") <= 0)\n        goto err;\n    rid = rd->responderId;\n    switch (rid->type) {\n    case V_OCSP_RESPID_NAME:\n        X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE);\n        break;\n    case V_OCSP_RESPID_KEY:\n        i2a_ASN1_STRING(bp, rid->value.byKey, V_ASN1_OCTET_STRING);\n        break;\n    }\n    if (BIO_printf(bp, "\\n    Produced At: ") <= 0)\n        goto err;\n    if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt))\n        goto err;\n    if (BIO_printf(bp, "\\n    Responses:\\n") <= 0)\n        goto err;\n    for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++) {\n        if (!sk_OCSP_SINGLERESP_value(rd->responses, i))\n            continue;\n        single = sk_OCSP_SINGLERESP_value(rd->responses, i);\n        cid = single->certId;\n        if (ocsp_certid_print(bp, cid, 4) <= 0)\n            goto err;\n        cst = single->certStatus;\n        if (BIO_printf(bp, "    Cert Status: %s",\n                       OCSP_cert_status_str(cst->type)) <= 0)\n            goto err;\n        if (cst->type == V_OCSP_CERTSTATUS_REVOKED) {\n            rev = cst->value.revoked;\n            if (BIO_printf(bp, "\\n    Revocation Time: ") <= 0)\n                goto err;\n            if (!ASN1_GENERALIZEDTIME_print(bp, rev->revocationTime))\n                goto err;\n            if (rev->revocationReason) {\n                l = ASN1_ENUMERATED_get(rev->revocationReason);\n                if (BIO_printf(bp,\n                               "\\n    Revocation Reason: %s (0x%lx)",\n                               OCSP_crl_reason_str(l), l) <= 0)\n                    goto err;\n            }\n        }\n        if (BIO_printf(bp, "\\n    This Update: ") <= 0)\n            goto err;\n        if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate))\n            goto err;\n        if (single->nextUpdate) {\n            if (BIO_printf(bp, "\\n    Next Update: ") <= 0)\n                goto err;\n            if (!ASN1_GENERALIZEDTIME_print(bp, single->nextUpdate))\n                goto err;\n        }\n        if (BIO_write(bp, "\\n", 1) <= 0)\n            goto err;\n        if (!X509V3_extensions_print(bp,\n                                     "Response Single Extensions",\n                                     single->singleExtensions, flags, 8))\n            goto err;\n        if (BIO_write(bp, "\\n", 1) <= 0)\n            goto err;\n    }\n    if (!X509V3_extensions_print(bp, "Response Extensions",\n                                 rd->responseExtensions, flags, 4))\n        goto err;\n    if (X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0)\n        goto err;\n    for (i = 0; i < sk_X509_num(br->certs); i++) {\n        X509_print(bp, sk_X509_value(br->certs, i));\n        PEM_write_bio_X509(bp, sk_X509_value(br->certs, i));\n    }\n    ret = 1;\n err:\n    OCSP_BASICRESP_free(br);\n    return ret;\n}', 'OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp)\n{\n    OCSP_RESPBYTES *rb;\n    rb = resp->responseBytes;\n    if (!rb) {\n        OCSPerr(OCSP_F_OCSP_RESPONSE_GET1_BASIC, OCSP_R_NO_RESPONSE_DATA);\n        return NULL;\n    }\n    if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) {\n        OCSPerr(OCSP_F_OCSP_RESPONSE_GET1_BASIC, OCSP_R_NOT_BASIC_RESPONSE);\n        return NULL;\n    }\n    return ASN1_item_unpack(rb->response, ASN1_ITEM_rptr(OCSP_BASICRESP));\n}', 'long ASN1_INTEGER_get(const ASN1_INTEGER *a)\n{\n    int neg = 0, i;\n    long r = 0;\n    if (a == NULL)\n        return (0L);\n    i = a->type;\n    if (i == V_ASN1_NEG_INTEGER)\n        neg = 1;\n    else if (i != V_ASN1_INTEGER)\n        return -1;\n    if (a->length > (int)sizeof(long)) {\n        return -1;\n    }\n    if (a->data == NULL)\n        return 0;\n    for (i = 0; i < a->length; i++) {\n        r <<= 8;\n        r |= (unsigned char)a->data[i];\n    }\n    if (neg)\n        r = -r;\n    return (r);\n}', 'int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)\n{\n    char *v;\n    int gmt = 0;\n    int i;\n    int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;\n    char *f = NULL;\n    int f_len = 0;\n    i = tm->length;\n    v = (char *)tm->data;\n    if (i < 12)\n        goto err;\n    if (v[i - 1] == \'Z\')\n        gmt = 1;\n    for (i = 0; i < 12; i++)\n        if ((v[i] > \'9\') || (v[i] < \'0\'))\n            goto err;\n    y = (v[0] - \'0\') * 1000 + (v[1] - \'0\') * 100\n        + (v[2] - \'0\') * 10 + (v[3] - \'0\');\n    M = (v[4] - \'0\') * 10 + (v[5] - \'0\');\n    if ((M > 12) || (M < 1))\n        goto err;\n    d = (v[6] - \'0\') * 10 + (v[7] - \'0\');\n    h = (v[8] - \'0\') * 10 + (v[9] - \'0\');\n    m = (v[10] - \'0\') * 10 + (v[11] - \'0\');\n    if (tm->length >= 14 &&\n        (v[12] >= \'0\') && (v[12] <= \'9\') &&\n        (v[13] >= \'0\') && (v[13] <= \'9\')) {\n        s = (v[12] - \'0\') * 10 + (v[13] - \'0\');\n        if (tm->length >= 15 && v[14] == \'.\') {\n            int l = tm->length;\n            f = &v[14];\n            f_len = 1;\n            while (14 + f_len < l && f[f_len] >= \'0\' && f[f_len] <= \'9\')\n                ++f_len;\n        }\n    }\n    if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",\n                   mon[M - 1], d, h, m, s, f_len, f, y,\n                   (gmt) ? " GMT" : "") <= 0)\n        return (0);\n    else\n        return (1);\n err:\n    BIO_write(bp, "Bad time value", 14);\n    return (0);\n}']