sun.security.krb5.Confounder Java Examples
The following examples show how to use
sun.security.krb5.Confounder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalSeqNumber.java From hottub with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #2
Source File: LocalSeqNumber.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #3
Source File: LocalSeqNumber.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #4
Source File: LocalSeqNumber.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #5
Source File: LocalSeqNumber.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #6
Source File: LocalSeqNumber.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #7
Source File: LocalSeqNumber.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #8
Source File: LocalSeqNumber.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #9
Source File: LocalSeqNumber.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #10
Source File: LocalSeqNumber.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #11
Source File: LocalSeqNumber.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #12
Source File: LocalSeqNumber.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public synchronized void randInit() { /* * Sequence numbers fall in the range 0 through 2^32 - 1 and wrap * to zero following the value 2^32 - 1. * Previous implementations used signed sequence numbers. * Workaround implementation incompatibilities by not generating * initial sequence numbers greater than 2^30, as done * in MIT distribution. */ // get the random confounder byte[] data = Confounder.bytes(4); data[0] = (byte)(data[0] & 0x3f); int result = ((data[3] & 0xff) | ((data[2] & 0xff) << 8) | ((data[1] & 0xff) << 16) | ((data[0] & 0xff) << 24)); if (result == 0) { result = 1; } lastSeqNumber = result; }
Example #13
Source File: RsaMd5DesCksumType.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateRawChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #14
Source File: WrapToken.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #15
Source File: RsaMd5DesCksumType.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #16
Source File: WrapToken.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #17
Source File: WrapToken.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #18
Source File: WrapToken.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #19
Source File: RsaMd5DesCksumType.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #20
Source File: WrapToken.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #21
Source File: RsaMd5DesCksumType.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateRawChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #22
Source File: RsaMd5DesCksumType.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #23
Source File: WrapToken.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #24
Source File: WrapToken.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #25
Source File: WrapToken.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #26
Source File: RsaMd5DesCksumType.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #27
Source File: RsaMd5DesCksumType.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #28
Source File: RsaMd5DesCksumType.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Calculates keyed checksum. * @param data the data used to generate the checksum. * @param size length of the data. * @param key the key used to encrypt the checksum. * @return keyed checksum. * * @modified by Yanni Zhang, 12/08/99. */ public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage) throws KrbCryptoException { //prepend confounder byte[] new_data = new byte[size + confounderSize()]; byte[] conf = Confounder.bytes(confounderSize()); System.arraycopy(conf, 0, new_data, 0, confounderSize()); System.arraycopy(data, 0, new_data, confounderSize(), size); //calculate md5 cksum byte[] mdc_cksum = calculateChecksum(new_data, new_data.length); byte[] cksum = new byte[cksumSize()]; System.arraycopy(conf, 0, cksum, 0, confounderSize()); System.arraycopy(mdc_cksum, 0, cksum, confounderSize(), cksumSize() - confounderSize()); //compute modified key byte[] new_key = new byte[keySize()]; System.arraycopy(key, 0, new_key, 0, key.length); for (int i = 0; i < new_key.length; i++) new_key[i] = (byte)(new_key[i] ^ 0xf0); //check for weak keys try { if (DESKeySpec.isWeak(new_key, 0)) { new_key[7] = (byte)(new_key[7] ^ 0xF0); } } catch (InvalidKeyException ex) { // swallow, since it should never happen } byte[] ivec = new byte[new_key.length]; //des-cbc encrypt byte[] enc_cksum = new byte[cksum.length]; Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true); return enc_cksum; }
Example #29
Source File: WrapToken.java From hottub with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }
Example #30
Source File: WrapToken.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException { super(Krb5Token.WRAP_ID, context); confounder = Confounder.bytes(CONFOUNDER_SIZE); padding = getPadding(dataLen); dataSize = confounder.length + dataLen + padding.length; this.dataBytes = dataBytes; this.dataOffset = dataOffset; this.dataLen = dataLen; /* debug("\nWrapToken cons: data to wrap is [" + getHexBytes(confounder) + " " + getHexBytes(dataBytes, dataOffset, dataLen) + " " + // padding is never null for Wrap getHexBytes(padding) + "]\n"); */ genSignAndSeqNumber(prop, confounder, dataBytes, dataOffset, dataLen, padding); /* * If the application decides to ask for privacy when the context * did not negotiate for it, do not provide it. The peer might not * have support for it. The app will realize this with a call to * pop.getPrivacy() after wrap(). */ if (!context.getConfState()) prop.setPrivacy(false); privacy = prop.getPrivacy(); }