Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cryptix.util.checksum
Class PRZ24

    java.lang.Object
      |
      +--cryptix.util.checksum.PRZ24

public class PRZ24
extends java.lang.Object
implements java.util.zip.Checksum

Checksum subclass for calculating a 24-bit PGP-compatible CRC.

Notes on making a good 24-bit CRC: [FH]

The primitive irreducible polynomial of degree 23 over GF(2), 040435651 (octal), comes from Appendix C of "Error Correcting Codes, 2nd edition" by Peterson and Weldon, page 490. This polynomial was chosen for its uniform density of ones and zeros, which has better error detection properties than polynomials with a minimal number of nonzero terms. Multiplying this primitive degree-23 polynomial by the polynomial x + 1 yields the additional property of detecting any odd number of bits in error, which means it adds parity. This approach was recommended by Neal Glover.

To multiply the polynomial 040435651 by (x + 1), shift it left 1 bit and bitwise add (xor) the unshifted version back in. Dropping the unused upper bit (bit 24) produces a CRC-24 generator bitmask of 041446373 octal, or 0x864CFB (hex).

You can detect spurious leading zeros or framing errors in the message by initializing the CRC accumulator to some agreed-upon nonzero "random- like" value, but this is a bit nonstandard.

General notes:

These CRC functions are derived from code in chapter 19 of the book "C Programmer's Guide to Serial Communications", by Joe Campbell. Generalized to any CRC width by Philip Zimmermann.

Adapted from PGP, by Philip Zimmermann, source file `armor.c`.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.1.1.1 $

Since:
  Cryptix 2.2.2
Author:
  FH, Raif S. Naffah

Constructor Summary
`PRZ24()`

Method Summary
`long` | `getValue()` Returns the value in the CRC accumulator.
`void` | `reset()` Resets to start processing a new CRC.
`void` | `update(byte[] buffer, int offset, int length)` Processes a buffer of bytes into the CRC accumulator.
`void` | `update(int n)` Accumulates 1 byte into the CRC accumulator.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PRZ24

    public PRZ24()

Method Detail

### reset

    public void reset()

  Resets to start processing a new CRC.
  Specified by:
    reset in interface java.util.zip.Checksum

### update

    public void update(byte[] buffer,
                       int offset,
                       int length)

  Processes a buffer of bytes into the CRC accumulator.
  Specified by:
    update in interface java.util.zip.Checksum
  Parameters:
    `buffer` - buffer data.
    `offset` - offset into buffer.
    `length` - number of bytes to consider.

### update

    public void update(int n)

  Accumulates 1 byte into the CRC accumulator.
  Specified by:
    update in interface java.util.zip.Checksum

### getValue

    public long getValue()

  Returns the value in the CRC accumulator.
  Specified by:
    getValue in interface java.util.zip.Checksum

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) 1995-2000 The Cryptix Foundation Ltd. All rights reserved.