summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau
AgeCommit message (Expand)Author
2014-06-10drm/nouveau/ibus: add GK20A supportAlexandre Courbot
2014-06-10drm/nvc0/bar: support chips without BAR3Alexandre Courbot
2014-06-10drm/nouveau/bar: only ioremap BAR3 if it existsAlexandre Courbot
2014-06-05Merge commit '9e9a928eed8796a0a1aaed7e0b676db86ba84594' into drm-nextDave Airlie
2014-06-04drm/nouveau: replace drm_get_connector_name() with direct name field useJani Nikula
2014-05-22Merge branch 'drm-nouveau-next' of git://anongit.freedesktop.org/git/nouveau/...Dave Airlie
2014-05-20drm/gf119-/disp: fix nasty bug which can clobber SOR0's clock setupBen Skeggs
2014-05-20drm/nvd9/therm: handle another kind of PWM fanMartin Peres
2014-05-07Merge branch 'drm-nouveau-next' of git://anongit.freedesktop.org/git/nouveau/...Dave Airlie
2014-05-02drm/gm107/gr: bump attrib cb size quite a bitBen Skeggs
2014-05-02drm/nouveau: fix another lock unbalance in nouveau_crtc_page_flipMaarten Lankhorst
2014-05-02drm/nouveau/bios: fix shadowing from PROM on big-endian systemsBen Skeggs
2014-05-02drm/nouveau/acpi: allow non-optimus setups to load vbios from acpiIlia Mirkin
2014-04-23drm: Rip out totally bogus vga_switcheroo->can_switch lockingDaniel Vetter
2014-04-18drm/nouveau/bios: fix a bit shift error introduced by 457e77bSergei Antonov
2014-04-08Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linuxLinus Torvalds
2014-04-05Merge tag 'drm-intel-fixes-2014-04-04' of git://anongit.freedesktop.org/drm-i...Dave Airlie
2014-04-02Merge branch 'primary-plane' of git://people.freedesktop.org/~robclark/linux ...Dave Airlie
2014-04-02drm/nouveau: don't suspend/resume display on runtime s/rDave Airlie
2014-04-01drm: Replace crtc fb with primary plane fb (v3)Matt Roper
2014-04-01Merge tag 'pm+acpi-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...Linus Torvalds
2014-03-31Merge tag 'v3.14' into drm-intel-next-queuedDaniel Vetter
2014-03-27drm/nouveau: fail runtime pm properly.Dave Airlie
2014-03-26drm/nouveau: fix missing newlineAlexandre Courbot
2014-03-26drm/nouveau/bios: fetch the vbios from PROM using only aligned 32-bit accessesMartin Peres
2014-03-26drm/nouveau/therm: let the vbios decide on the automatic fan management modeMartin Peres
2014-03-26drm/nvd7/therm: handle another kind of PWM fansMartin Peres
2014-03-26drm/nouveau/pm/fan: drop the fan lock in fan_update() before reschedulingMartin Peres
2014-03-26drm/nouveau: fix small thinko in vblank timestamping.Mario Kleiner
2014-03-26drm/nouveau/therm: check for sensor presence with requested mode, not currentBen Skeggs
2014-03-26drm/nouveau/disp/dp: allow 540MHz data rateIlia Mirkin
2014-03-26drm/nouveau: recognise higher link rate for available dp bw calculationsBen Skeggs
2014-03-26drm/nouveau/disp: limit dp capabilities as per dcbBen Skeggs
2014-03-26drm/nva3/fbram: restrict training pattern setup to GT218Ben Skeggs
2014-03-26drm/nva3/devinit: restrict script access to some PFB regsBen Skeggs
2014-03-26drm/nouveau/devinit: add interface to check if a mmio access by scripts is okBen Skeggs
2014-03-26drm/nouveau/bios: have strap reads show on devinit spam debug levelBen Skeggs
2014-03-26drm/nv50/gpio: fixup reset for gpios >= 16Ben Skeggs
2014-03-26drm/nv50/gpio: exclude sense value from mask when changing registersBen Skeggs
2014-03-26drm/gk104/gr: therm magic needed on some kepler boardsBen Skeggs
2014-03-26drm/gm107/gr: initial supportBen Skeggs
2014-03-26drm/gf100-/gf: fix a stupid typo, waiting on wrong signal for mmctxBen Skeggs
2014-03-26drm/nouveau/bios: parsing of some random table needed to bring up grBen Skeggs
2014-03-26drm/nv50/bar: fix plymouth issues on certain efi macbooksBen Skeggs
2014-03-26drm/nouveau: fix fbcon not being accelerated after suspendBen Skeggs
2014-03-26drm/gf100-/gr: split ppc state into its subunitsBen Skeggs
2014-03-26drm/gf100-/gf: split tpc state into its subunitsBen Skeggs
2014-03-26drm/gf100-/gr: split gpc state into its subunitsBen Skeggs
2014-03-26drm/gf100-/gr: tidy reg/ctx initval lists, mostly by giving them namesBen Skeggs
2014-03-26drm/gk110/gr: minor adjustment to some random initvalBen Skeggs
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <stdio.h>
#include <ctype.h>
#include "internal/cryptlib.h"
#include <openssl/asn1t.h>
#include <openssl/x509.h>
#include "internal/x509_int.h"
#include "internal/asn1_int.h"
#include "x509_lcl.h"

/*
 * Maximum length of X509_NAME: much larger than anything we should
 * ever see in practice.
 */

#define X509_NAME_MAX (1024 * 1024)

static int x509_name_ex_d2i(ASN1_VALUE **val,
                            const unsigned char **in, long len,
                            const ASN1_ITEM *it,
                            int tag, int aclass, char opt, ASN1_TLC *ctx);

static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out,
                            const ASN1_ITEM *it, int tag, int aclass);
static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it);
static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it);

static int x509_name_encode(X509_NAME *a);
static int x509_name_canon(X509_NAME *a);
static int asn1_string_canon(ASN1_STRING *out, const ASN1_STRING *in);
static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) * intname,
                          unsigned char **in);

static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
                              int indent,
                              const char *fname, const ASN1_PCTX *pctx);

ASN1_SEQUENCE(X509_NAME_ENTRY) = {
        ASN1_SIMPLE(X509_NAME_ENTRY, object, ASN1_OBJECT),
        ASN1_SIMPLE(X509_NAME_ENTRY, value, ASN1_PRINTABLE)
} ASN1_SEQUENCE_END(X509_NAME_ENTRY)

IMPLEMENT_ASN1_FUNCTIONS(X509_NAME_ENTRY)
IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME_ENTRY)

/*
 * For the "Name" type we need a SEQUENCE OF { SET OF X509_NAME_ENTRY } so
 * declare two template wrappers for this
 */

ASN1_ITEM_TEMPLATE(X509_NAME_ENTRIES) =
        ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, RDNS, X509_NAME_ENTRY)
static_ASN1_ITEM_TEMPLATE_END(X509_NAME_ENTRIES)

ASN1_ITEM_TEMPLATE(X509_NAME_INTERNAL) =
        ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, Name, X509_NAME_ENTRIES)
static_ASN1_ITEM_TEMPLATE_END(X509_NAME_INTERNAL)

/*
 * Normally that's where it would end: we'd have two nested STACK structures
 * representing the ASN1. Unfortunately X509_NAME uses a completely different
 * form and caches encodings so we have to process the internal form and
 * convert to the external form.
 */

static const ASN1_EXTERN_FUNCS x509_name_ff = {
    NULL,
    x509_name_ex_new,
    x509_name_ex_free,
    0,                          /* Default clear behaviour is OK */
    x509_name_ex_d2i,
    x509_name_ex_i2d,
    x509_name_ex_print
};

IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff)

IMPLEMENT_ASN1_FUNCTIONS(X509_NAME)

IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME)

static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it)
{
    X509_NAME *ret = OPENSSL_zalloc(sizeof(*ret));

    if (ret == NULL)
        goto memerr;
    if ((ret->entries = sk_X509_NAME_ENTRY_new_null()) == NULL)
        goto memerr;
    if ((ret->bytes = BUF_MEM_new()) == NULL)
        goto memerr;
    ret->modified = 1;
    *val = (ASN1_VALUE *)ret;
    return 1;

 memerr:
    ASN1err(ASN1_F_X509_NAME_EX_NEW, ERR_R_MALLOC_FAILURE);
    if (ret) {
        sk_X509_NAME_ENTRY_free(ret->entries);
        OPENSSL_free(ret);
    }
    return 0;
}

static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
{
    X509_NAME *a;

    if (!pval || !*pval)
        return;
    a = (X509_NAME *)*pval;

    BUF_MEM_free(a->bytes);
    sk_X509_NAME_ENTRY_pop_free(a->entries, X509_NAME_ENTRY_free);
    OPENSSL_free(a->canon_enc);
    OPENSSL_free(a);
    *pval = NULL;
}

static void name_entry_stack_free(STACK_OF(X509_NAME_ENTRY) *ents)
{
    sk_X509_NAME_ENTRY_pop_free(ents, X509_NAME_ENTRY_free);
}

static int x509_name_ex_d2i(ASN1_VALUE **val,
                            const unsigned char **in, long len,
                            const ASN1_ITEM *it, int tag, int aclass,
                            char opt, ASN1_TLC *ctx)
{
    const unsigned char *p = *in, *q;
    union {
        STACK_OF(STACK_OF_X509_NAME_ENTRY) *s;
        ASN1_VALUE *a;
    } intname = {
        NULL
    };
    union {
        X509_NAME *x;
        ASN1_VALUE *a;
    } nm = {
        NULL
    };
    int i, j, ret;
    STACK_OF(X509_NAME_ENTRY) *entries;
    X509_NAME_ENTRY *entry;
    if (len > X509_NAME_MAX)
        len = X509_NAME_MAX;
    q = p;

    /* Get internal representation of Name */
    ret = ASN1_item_ex_d2i(&intname.a,
                           &p, len, ASN1_ITEM_rptr(X509_NAME_INTERNAL),
                           tag, aclass, opt, ctx);

    if (ret <= 0)
        return ret;

    if (*val)
        x509_name_ex_free(val, NULL);
    if (!x509_name_ex_new(&nm.a, NULL))
        goto err;
    /* We've decoded it: now cache encoding */
    if (!BUF_MEM_grow(nm.x->bytes, p - q))
        goto err;
    memcpy(nm.x->bytes->data, q, p - q);

    /* Convert internal representation to X509_NAME structure */
    for (i = 0; i < sk_STACK_OF_X509_NAME_ENTRY_num(intname.s); i++) {
        entries = sk_STACK_OF_X509_NAME_ENTRY_value(intname.s, i);
        for (j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) {
            entry = sk_X509_NAME_ENTRY_value(entries, j);
            entry->set = i;
            if (!sk_X509_NAME_ENTRY_push(nm.x->entries, entry))
                goto err;
        }
    }
    /*
     * All entries have now been pushed to nm->x.entries
     * free up the stacks in intname.s but not the entries
     * themselves.
     */
    sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s, sk_X509_NAME_ENTRY_free);
    intname.s = NULL;
    ret = x509_name_canon(nm.x);
    if (!ret)
        goto err;
    nm.x->modified = 0;
    *val = nm.a;
    *in = p;
    return ret;

 err:
    /* If intname.s is not NULL only some entries exist in nm->x.entries:
     * zero references in nm->x.entries list. Since all entries exist
     * in intname.s we can free them all there
     */
    if (intname.s != NULL) {
        sk_X509_NAME_ENTRY_zero(nm.x->entries);
        sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s, name_entry_stack_free);
    }
    X509_NAME_free(nm.x);
    ASN1err(ASN1_F_X509_NAME_EX_D2I, ERR_R_NESTED_ASN1_ERROR);<