NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums General General Discussion v
« Previous 1 … 140 141 142 143 144 … 159 Next »
DVB-S and SoftCAM

 
  • 0 Vote(s) - 0 Average
DVB-S and SoftCAM
hack@d
Offline

Junior Member

Posts: 4
Threads: 1
Joined: Sep 2005
#1
2005-09-19, 03:31 AM
Does anyone know if there is a softcam plugin for this software or any plans of one being developed ?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,684
Threads: 767
Joined: Nov 2003
#2
2005-09-19, 04:00 AM
No theres not. I currently have no plans to add support for this. Sorry.
hack@d
Offline

Junior Member

Posts: 4
Threads: 1
Joined: Sep 2005
#3
2005-09-19, 04:00 AM
Code:
/*
* Softcam plugin to VDR (C++)
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This code 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to [url]http://www.gnu.org/copyleft/gpl.html[/url]
*/

#if defined(NAGRA) && defined(OPENSSL)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#ifndef TESTER
#include <openssl/bn.h>
#endif

#include <vdr/tools.h>
#include <vdr/thread.h>

#include "common.h"
#ifndef TESTER
#include "sc.h"
#include "system.h"
#include "system-common.h"
#include "data.h"
#include "misc.h"
#include "opts.h"
#include "crypto.h"
#include "vdr-compat.h"
#endif

#define SYSTEM_NAGRA         0x1800
#define SYSTEM_NAGRA2        0x1801
#define SYSTEM_NAGRA_BEV     0x1234

#define SYSTEM_NAME          "Nagra"
#define SYSTEM_PRI           -10
#define SYSTEM_CAN_HANDLE(x) ((x)==SYSTEM_NAGRA || (x)==SYSTEM_NAGRA2 || (x)==SYSTEM_NAGRA_BEV)

#define FILEMAP_DOMAIN       "nagra"

//#define DEBUG_EMU      // debug CardEmu (very verbose!)
//#define DEBUG_EMU_0x80 // if the above is enabled, limit output to range x080-0xc0
//#define DEBUG_STAT     // give some statistics on CardEmu
//#define DEBUG_MAP      // debug file mapping code
//#define DEBUG_NAGRA    // debug Nagra crypt code

#ifdef DEBUG_EMU
#ifdef DEBUG_EMU_0x80
static bool pc80flag=false;
#define de(x) { if(pc80flag) { (x); } }
#else
#define de(x) { (x); }
#endif
#else
#define de(x) ;
#endif

#ifdef DEBUG_NAGRA
#define dn(a) { a; }
#else
#define dn(a) ;
#endif

/*__NAGRA2__START___________________________________________*/

typedef unsigned char byte;

typedef unsigned short word16; /* values are 0-65535 */
typedef unsigned long word32; /* values are 0-4294967295 */
typedef word16 uint16;
#define low16(x) (x)

#define IDEAROUNDS 8
#define IDEAKEYLEN (6*IDEAROUNDS+4)

/* Type definitions.
*/
typedef unsigned int NN_DIGIT;
typedef unsigned short int NN_HALF_DIGIT;

/* RSA key lengths.
*/
#define MIN_RSA_MODULUS_BITS 508
#define MAX_RSA_MODULUS_BITS 1024
#define MAX_RSA_MODULUS_LEN ((MAX_RSA_MODULUS_BITS + 7) / 8)
#define MAX_RSA_PRIME_BITS ((MAX_RSA_MODULUS_BITS + 1) / 2)
#define MAX_RSA_PRIME_LEN ((MAX_RSA_PRIME_BITS + 7) / 8)

/* Constants.

   Note: MAX_NN_DIGITS is long enough to hold any RSA modulus, plus
   one more digit as required by R_GeneratePEMKeys (for n and phiN,
   whose lengths must be even). All natural numbers have at most
   MAX_NN_DIGITS digits, except for double-length intermediate values
   in NN_Mult (t), NN_ModMult (t), NN_ModInv (w), and NN_Div (c).
*/
/* Length of digit in bits */
#define NN_DIGIT_BITS 32
#define NN_HALF_DIGIT_BITS 16
/* Length of digit in bytes */
#define NN_DIGIT_LEN (NN_DIGIT_BITS / 8)
/* Maximum length in digits */
#define MAX_NN_DIGITS \
  ((MAX_RSA_MODULUS_LEN + NN_DIGIT_LEN - 1) / NN_DIGIT_LEN + 1)
/* Maximum digits */
#define MAX_NN_DIGIT 0xffffffff
#define MAX_NN_HALF_DIGIT 0xffff

/* Macros.
*/
#define LOW_HALF(x) ((x) & MAX_NN_HALF_DIGIT)
#define HIGH_HALF(x) (((x) >> NN_HALF_DIGIT_BITS) & MAX_NN_HALF_DIGIT)
#define TO_HIGH_HALF(x) (((NN_DIGIT)(x)) << NN_HALF_DIGIT_BITS)
#define DIGIT_MSB(x) (unsigned int)(((x) >> (NN_DIGIT_BITS - 1)) & 1)
#define DIGIT_2MSB(x) (unsigned int)(((x) >> (NN_DIGIT_BITS - 2)) & 3)
#define NN_ASSIGN_DIGIT(a, b, digits) {NN_AssignZero (a, digits); a[0] = b;}
#define NN_EQUAL(a, b, digits) (! NN_Cmp (a, b, digits))
#define NN_EVEN(a, digits) (((digits) == 0) || ! (a[0] & 1))

/* Computes a = b * c, where b and c are digits.

   Lengths: a[2].
*/
void NN_DigitMult (NN_DIGIT a[], NN_DIGIT b, NN_DIGIT c)
{
  NN_DIGIT t, u;
  NN_HALF_DIGIT bHigh, bLow, cHigh, cLow;

  bHigh = (NN_HALF_DIGIT)HIGH_HALF (b);
  bLow = (NN_HALF_DIGIT)LOW_HALF (b);
  cHigh = (NN_HALF_DIGIT)HIGH_HALF (c);
  cLow = (NN_HALF_DIGIT)LOW_HALF (c);

  a[0] = (NN_DIGIT)bLow * (NN_DIGIT)cLow;
  t = (NN_DIGIT)bLow * (NN_DIGIT)cHigh;
  u = (NN_DIGIT)bHigh * (NN_DIGIT)cLow;
  a[1] = (NN_DIGIT)bHigh * (NN_DIGIT)cHigh;
  
  if ((t += u) < u)
    a[1] += TO_HIGH_HALF (1);
  u = TO_HIGH_HALF (t);
  
  if ((a[0] += u) < u)
    a[1]++;
  a[1] += HIGH_HALF (t);
}

/* Sets a = b / c, where a and c are digits.

   Lengths: b[2].
   Assumes b[1] < c and HIGH_HALF (c) > 0. For efficiency, c should be
   normalized.
*/
void NN_DigitDiv (NN_DIGIT *a, NN_DIGIT b[], NN_DIGIT c)
{
  NN_DIGIT t[2], u, v;
  NN_HALF_DIGIT aHigh, aLow, cHigh, cLow;

  cHigh = (NN_HALF_DIGIT)HIGH_HALF (c);
  cLow = (NN_HALF_DIGIT)LOW_HALF (c);

  t[0] = b[0];
  t[1] = b[1];

  /* Underestimate high half of quotient and subtract.
   */
  if (cHigh == MAX_NN_HALF_DIGIT)
    aHigh = (NN_HALF_DIGIT)HIGH_HALF (t[1]);
  else
    aHigh = (NN_HALF_DIGIT)(t[1] / (cHigh + 1));
  u = (NN_DIGIT)aHigh * (NN_DIGIT)cLow;
  v = (NN_DIGIT)aHigh * (NN_DIGIT)cHigh;
  if ((t[0] -= TO_HIGH_HALF (u)) > (MAX_NN_DIGIT - TO_HIGH_HALF (u)))
    t[1]--;
  t[1] -= HIGH_HALF (u);
  t[1] -= v;

  /* Correct estimate.
   */
  while ((t[1] > cHigh) ||
         ((t[1] == cHigh) && (t[0] >= TO_HIGH_HALF (cLow)))) {
    if ((t[0] -= TO_HIGH_HALF (cLow)) > MAX_NN_DIGIT - TO_HIGH_HALF (cLow))
      t[1]--;
    t[1] -= cHigh;
    aHigh++;
  }

  /* Underestimate low half of quotient and subtract.
   */
  if (cHigh == MAX_NN_HALF_DIGIT)
    aLow = (NN_HALF_DIGIT)LOW_HALF (t[1]);
  else
    aLow =
      (NN_HALF_DIGIT)((TO_HIGH_HALF (t[1]) + HIGH_HALF (t[0])) / (cHigh + 1));
  u = (NN_DIGIT)aLow * (NN_DIGIT)cLow;
  v = (NN_DIGIT)aLow * (NN_DIGIT)cHigh;
  if ((t[0] -= u) > (MAX_NN_DIGIT - u))
    t[1]--;
  if ((t[0] -= TO_HIGH_HALF (v)) > (MAX_NN_DIGIT - TO_HIGH_HALF (v)))
    t[1]--;
  t[1] -= HIGH_HALF (v);

  /* Correct estimate.
   */
  while ((t[1] > 0) || ((t[1] == 0) && t[0] >= c)) {
    if ((t[0] -= c) > (MAX_NN_DIGIT - c))
      t[1]--;
    aLow++;
  }
  
  *a = TO_HIGH_HALF (aHigh) + aLow;
}

/* Returns the significant length of a in bits, where a is a digit.
*/
unsigned int NN_DigitBits (NN_DIGIT a)
{
  unsigned int i;
  
  for (i = 0; i < NN_DIGIT_BITS; i++, a >>= 1)
    if (a == 0)
      break;
    
  return (i);
}

/* Returns the significant length of a in digits.

   Lengths: a[digits].
*/
unsigned int NN_Digits (NN_DIGIT *a, unsigned int digits)
{
  int i;
  
  for (i = digits - 1; i >= 0; i--)
    if (a[i])
      break;

  return (i + 1);
}

/* Assigns a = 0.

   Lengths: a[digits].
*/
void NN_AssignZero (NN_DIGIT *a, unsigned int digits)
{
  unsigned int i;

  for (i = 0; i < digits; i++)
    a[i] = 0;
}

/* Assigns a = b.

   Lengths: a[digits], b[digits].
*/
void NN_Assign (NN_DIGIT *a, NN_DIGIT *b, unsigned int digits)
{
  unsigned int i;

  for (i = 0; i < digits; i++)
    a[i] = b[i];
}

/* Returns sign of a - b.

   Lengths: a[digits], b[digits].
*/
int NN_Cmp (NN_DIGIT *a, NN_DIGIT *b, unsigned int digits)
{
  int i;
  
  for (i = digits - 1; i >= 0; i--) {
    if (a[i] > b[i])
      return (1);
    if (a[i] < b[i])
      return (-1);
  }

  return (0);
}

/* Computes a = b - c. Returns borrow.

   Lengths: a[digits], b[digits], c[digits].
*/
NN_DIGIT NN_Sub (NN_DIGIT *a, NN_DIGIT *b, NN_DIGIT *c, unsigned int digits)
{
  NN_DIGIT ai, borrow;
  unsigned int i;

  borrow = 0;

  for (i = 0; i < digits; i++) {
    if ((ai = b[i] - borrow) > (MAX_NN_DIGIT - borrow))
      ai = MAX_NN_DIGIT - c[i];
    else if ((ai -= c[i]) > (MAX_NN_DIGIT - c[i]))
      borrow = 1;
    else
      borrow = 0;
    a[i] = ai;
  }

  return (borrow);
}

/* Computes a = b * 2^c (i.e., shifts left c bits), returning carry.

   Lengths: a[digits], b[digits].
   Requires c < NN_DIGIT_BITS.
*/
NN_DIGIT NN_LShift (NN_DIGIT *a, NN_DIGIT *b, unsigned int c, unsigned int digits)
{
  NN_DIGIT bi, carry;
  unsigned int i, t;
  
  if (c >= NN_DIGIT_BITS)
    return (0);
  
  t = NN_DIGIT_BITS - c;

  carry = 0;

  for (i = 0; i < digits; i++) {
    bi = b[i];
    a[i] = (bi << c) | carry;
    carry = c ? (bi >> t) : 0;
  }
  
  return (carry);
}

/* Computes a = c div 2^c (i.e., shifts right c bits), returning carry.

   Lengths: a[digits], b[digits].
   Requires: c < NN_DIGIT_BITS.
*/
NN_DIGIT NN_RShift (NN_DIGIT *a, NN_DIGIT *b, unsigned int c, unsigned int digits)
{
  NN_DIGIT bi, carry;
  int i;
  unsigned int t;
  
  if (c >= NN_DIGIT_BITS)
    return (0);
  
  t = NN_DIGIT_BITS - c;

  carry = 0;

  for (i = digits - 1; i >= 0; i--) {
    bi = b[i];
    a[i] = (bi >> c) | carry;
    carry = c ? (bi << t) : 0;
  }
  
  return (carry);
}

Continued...
hack@d
Offline

Junior Member

Posts: 4
Threads: 1
Joined: Sep 2005
#4
2005-09-19, 04:06 AM (This post was last modified: 2005-09-19, 04:11 AM by hack@d.)
Sorry didn't see your reply before my last post...if anyone is interest in the source goto hxxp://vdr.bluox.org/uc/files/system-nagra.c
daphatty
Offline

Posting Freak

Posts: 1,032
Threads: 85
Joined: Feb 2005
#5
2005-09-19, 04:07 AM
Looks like a former media portal user looking for an alternative...
hack@d
Offline

Junior Member

Posts: 4
Threads: 1
Joined: Sep 2005
#6
2005-09-19, 04:14 AM
Not really, just thought that next to mythTV this is the best looking product around. And the more options available the more potential exposure for this one.
uberdown
Offline

Junior Member

Posts: 1
Threads: 0
Joined: Oct 2005
#7
2005-10-30, 04:59 PM
what is this file supposed to be named, & where should it be placed?

thanks
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,684
Threads: 767
Joined: Nov 2003
#8
2005-10-30, 05:02 PM
The file doesnt have anything with GB-PVR.

He was just suggesting I should implement support for this softcam, and was supplying information that he thought would be useful for me if I did this.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode