summaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/cxacru.c
AgeCommit message (Expand)Author
2010-09-09Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/ne...David S. Miller
2010-09-08cxacru: ignore cx82310_eth devicesOndrej Zary
2010-09-03USB: cxacru: Use a bulk/int URB to access the command endpointSimon Arlott
2010-08-10usb: conexant: fixed spacing and brace coding style issuesNicolas Kaiser
2010-07-09usb/atm/cxacru.c: call atm_dev_signal_change() when signal changes.Karl Hiramoto
2010-03-02USB: cxacru: increment driver versionSimon Arlott
2010-03-02USB: cxacru: remove cxacru-cf.bin loaderSimon Arlott
2010-03-02USB: cxacru: add write-only sysfs attribute for modem configurationSimon Arlott
2010-03-02USB: cxacru: firmware writes on OHCI are slow, log progressSimon Arlott
2010-03-02USB: cxacru: document how to interact with the flash memorySimon Arlott
2010-03-02USB: cxacru: check device isn't being removed during sysfs callsSimon Arlott
2010-03-02USB: cxacru: check data length is not negativeSimon Arlott
2010-03-02USB: cxacru: return an empty value for modulation if there is no connectionSimon Arlott
2009-05-08USB: cxacru: Fix negative dB outputSimon Arlott
2009-03-17USB: atm/cxacru, fix lock imbalanceJiri Slaby
2008-10-27net: convert more to %pMJohannes Berg
2008-08-13USB: cxacru: Fix printk format flag in error messageSimon Arlott
2008-07-21USB: AccessRunner: avoid unnecessary memsetChristophe Jaillet
2008-07-10cxacru: treat firmware data as constDavid Woodhouse
2008-04-28drivers/usb annotations and fixesAl Viro
2008-04-24USB: remove unnecessary type casting of urb->contextMing Lei
2007-10-12USB: cxacru: Use appropriate logging for errorsSimon Arlott
2007-08-22USB: unkill cxacru atm driverOliver Neukum
2007-07-19USB: atm: cxacru: clean up urb->status usageGreg Kroah-Hartman
2007-07-12USB: cxacru: Cleanup sysfs attribute codeSimon Arlott
2007-06-08USB: cxacru: ignore error trying to start ADSL in atm_startSimon Arlott
2007-06-08USB: cxacru: create sysfs attributes in atm_start instead of bindSimon Arlott
2007-04-27USB: cxacru: ADSL state managementSimon Arlott
2007-04-27USB: cxacru: export detailed device info through sysfsSimon Arlott
2006-11-22WorkStruct: make allyesconfigDavid Howells
2006-10-17cxacru: add the ZTE ZXDSL 852Duncan Sands
2006-10-05IRQ: Maintain regs pointer globally rather than passing to IRQ handlersDavid Howells
2006-01-31[PATCH] USBATM: semaphore to mutex conversionArjan van de Ven
2006-01-31[PATCH] USBATM: allow isochronous transferDuncan Sands
2006-01-31[PATCH] USBATM: kzalloc conversionDuncan Sands
2006-01-31[PATCH] USBATM: remove .ownerDuncan Sands
2006-01-31[PATCH] USBATM: add flags fieldDuncan Sands
2006-01-31[PATCH] USBATM: trivial modificationsDuncan Sands
2006-01-04[PATCH] USB: remove .owner field from struct usb_driverGreg Kroah-Hartman
2005-11-29[PATCH] Additional device ID for Conexant AccessRunner USB driverDave Jones
2005-09-08[PATCH] USB: URB_ASYNC_UNLINK flag removed from the kernelAlan Stern
2005-07-12[PATCH] USB ATM: line speed measured in Kb not KibDuncan Sands
2005-06-27[PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacruDuncan Sands
n306' href='#n306'>306 307 308 309 310 311
/* -*- c-basic-offset: 8; -*- */
/* proto_roaraudio.c: RoarAudio protocol support.
 * $Id$
 *
 *  Copyright (C) 2015      Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef HAVE_CONFIG_H
#   include <config.h>
#endif

#ifdef HAVE_INTTYPES_H
#   include <inttypes.h>
#endif

/* for htonl(). */
#ifdef HAVE_ARPA_INET_H
#   include <arpa/inet.h>
#endif

#ifdef _WIN32
#include <process.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <shoutidjc/shout.h>
#include "shout_private.h"

typedef enum {
    STATE_IDENT = 0,
    STATE_AUTH,
    STATE_NEW_STREAM,
    STATE_EXEC
} shout_roar_protocol_state_t;

typedef enum {
    CMD_IDENTIFY    = 1,
    CMD_AUTH        = 2,
    CMD_NEW_STREAM  = 3,
    CMD_EXEC_STREAM = 5,
    CMD_OK          = 254
} shout_roar_command_t;

#define STREAM_NONE ((uint16_t)0xFFFF)
#define HEADER_SIZE 10

static int command_send(shout_t                *self,
                        shout_roar_command_t    command,
                        uint16_t                stream,
                        const void             *data,
                        size_t                  datalen)
{
    uint8_t header[HEADER_SIZE];

    if (!self)
        return SHOUTERR_INSANE;

    if (datalen > 65535)
        return SHOUTERR_INSANE;

    if (datalen && !data)
        return SHOUTERR_INSANE;

    /* version.
     * While version 2 is already on it's way we still go for version 0
     * as it will work well for us and is defined as part of the core
     * every RoarAudio server MUST implement.
     */
    header[0] = 0;
    /* command ID. */
    header[1] = command;
    /* stream ID. First upper then lower byte. */
    header[2] = (stream & 0xFF00) >> 8;
    header[3] = (stream & 0x00FF);
    /* now 4 bytes of stream position.
     * This implementation doesn't need this so we
     * set it to all zeros.
     */
    header[4] = 0;
    header[5] = 0;
    header[6] = 0;
    header[7] = 0;
    /* Now body ("data") size. First upper then lower byte. */
    header[8] = (datalen & 0xFF00) >> 8;
    header[9] = (datal
/*
 * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (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 <openssl/opensslconf.h>
/*-
 * IMPLEMENTATION NOTES.
 *
 * As you might have noticed 32-bit hash algorithms:
 *
 * - permit SHA_LONG to be wider than 32-bit
 * - optimized versions implement two transform functions: one operating
 *   on [aligned] data in host byte order and one - on data in input
 *   stream byte order;
 * - share common byte-order neutral collector and padding function
 *   implementations, ../md32_common.h;
 *
 * Neither of the above applies to this SHA-512 implementations. Reasons
 * [in reverse order] are:
 *
 * - it's the only 64-bit hash algorithm for the moment of this writing,
 *   there is no need for common collector/padding implementation [yet];
 * - by supporting only one transform function [which operates on
 *   *aligned* data in input stream byte order, big-endian in this case]
 *   we minimize burden of maintenance in two ways: a) collector/padding
 *   function is simpler; b) only one transform function to stare at;
 * - SHA_LONG64 is required to be exactly 64-bit in order to be able to
 *   apply a number of optimizations to mitigate potential performance
 *   penalties caused by previous design decision;
 *
 * Caveat lector.
 *
 * Implementation relies on the fact that "long long" is 64-bit on
 * both 32- and 64-bit platforms. If some compiler vendor comes up
 * with 128-bit long long, adjustment to sha.h would be required.
 * As this implementation relies on 64-bit integer type, it's totally
 * inappropriate for platforms which don't support it, most notably
 * 16-bit platforms.
 */
#include <stdlib.h>
#include <string.h>

#include <openssl/crypto.h>
#include <openssl/sha.h>
#include <openssl/opensslv.h>

#include "internal/cryptlib.h"
#include "crypto/sha.h"

#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
    defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || \
    defined(__s390__) || defined(__s390x__) || \
    defined(__aarch64__) || \
    defined(SHA512_ASM)
# define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
#endif

#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
# define U64(C)     C##UI64
#elif defined(__arch64__)
# define U64(C)     C##UL
#else
# define U64(C)     C##ULL
#endif

int sha512_224_init(SHA512_CTX *c)
{
    c->h[0] = U64(0x8c3d37c819544da2);
    c->h[1] = U64(0x73e1996689dcd4d6);
    c->h[2] = U64(0x1dfab7ae32ff9c82);
    c->h[3] = U64(0x679dd514582f9fcf);
    c->h[4] = U64(0x0f6d2b697bd44da8);
    c->h[5] = U64(0x77e36f7304c48942);
    c->h[6] = U64(0x3f9d85a86a1d36c8);
    c->h[7] = U64(0x1112e6ad91d692a1);

    c->Nl = 0;
    c->Nh = 0;
    c->num = 0;
    c->md_len = SHA224_DIGEST_LENGTH;
    return 1;
}

int sha512_256_init(SHA512_CTX *c)
{
    c->h[0] = U64(0x22312194fc2bf72c);
    c->h[1] = U64(0x9f555fa3c84c64c2);
    c->h[2] = U64(0x2393b86b6f53b151);
    c->h[3] = U64(0x963877195940eabd);
    c->h[4] = U64(0x96283ee2a88effe3);
    c->h[5] = U64(0xbe5e1e2553863992);
    c->h[6] = U64(0x2b0199fc2c85b8aa);
    c->h[7] = U64(0x0eb72ddc81c52ca2);

    c->Nl = 0;
    c->Nh = 0;
    c->num = 0;
    c->md_len = SHA256_DIGEST_LENGTH;
    return 1;
}

int SHA384_Init(SHA512_CTX *c)
{
    c->h[0] = U64(0xcbbb9d5dc1059ed8);
    c->h[1] = U64(0x629a292a367cd507);
    c->h[2] = U64(0x9159015a3070dd17);
    c->h[3] = U64(0x152fecd8f70e5939);
    c->h[4] = U64(0x67332667ffc00b31);
    c->h[5] = U64(0x8eb44a8768581511);
    c->h[6] = U64(0xdb0c2e0d64f98fa7);
    c->h[7] = U64(0x47b5481dbefa4fa4);

    c->Nl = 0;
    c->Nh = 0;
    c->num = 0;
    c->md_len = SHA384_DIGEST_LENGTH;
    return 1;
}

int SHA512_Init(SHA512_CTX *c)
{
    c->h[0] = U64(0x6a09e667f3bcc908);
    c->h[1] = U64(0xbb67ae8584caa73b);
    c->h[2] = U64(0x3c6ef372fe94f82b);
    c->h[3] = U64(0xa54ff53a5f1d36f1);
    c->h[4] = U64(0x510e527fade682d1);
    c->h[5] = U64(0x9b05688c2b3e6c1f);
    c->h[6] = U64(0x1f83d9abfb41bd6b);
    c->h[7] = U64(0x5be0cd19137e2179);

    c->Nl = 0;
    c->Nh = 0;
    c->num = 0;
    c->md_len = SHA512_DIGEST_LENGTH;
    return 1;
}

#ifndef SHA512_ASM
static
#endif
void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num);

int SHA512_Final(unsigned char *md, SHA512_CTX *c)
{
    unsigned char *p = (unsigned char *)c->u.p;
    size_t n = c->num;

    p[n] = 0x80;                /* There always is a room for one */
    n++;
    if (n > (sizeof(c->u) - 16)) {
        memset(p + n, 0, sizeof(c->u) - n);
        n = 0;
        sha512_block_data_order(c, p, 1);
    }

    memset(p + n, 0, sizeof(c->u) - 16 - n);
#ifdef  B_ENDIAN
    c->u.d[SHA_LBLOCK - 2] = c->Nh;
    c->u.d[SHA_LBLOCK - 1] = c->Nl;
#else
    p[sizeof(c->u) - 1] = (unsigned char)(c->Nl);
    p[sizeof(c->u) - 2] = (