net.siisise.security.mode.CCM Maven / Gradle / Ivy
/*
* Copyright 2023 okome.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.siisise.security.mode;
import net.siisise.io.Packet;
import net.siisise.security.block.Block;
import net.siisise.security.mac.CBCMAC;
/**
* TLS 1.3用
* @deprecated まだない
*/
@Deprecated
public class CCM extends StreamMode {
byte[] nonce;
/**
* The associated data String
*/
byte[] ac;
CBCMAC cbc;
CTR ctr;
Packet x;
public CCM(Block block) {
super(block);
if (block.getBlockLength() != 128 ) {
throw new SecurityException("block length");
}
}
/**
* nonce と A: The associated data string
* @param params nonce N, associated data A
*/
@Override
public void init(byte[][] params) {
block.init(in(2,params));
nonce = params[params.length - 2]; // N
ac = params[params.length - 1]; // A
byte[] y0 = block.encrypt(ac);
}
// (N, A, P) B
void genb() {
}
// Y0 = CIPHk(B0)
// Yi = CIPH(Bi ^ Y(i-1))
// T = MSB Tlen(Yr)
// Ctrm
//
void geny() {
}
/**
*
* C = (P ^ MSB Plen(S)) || (T ^ MSB Tlen(S0))
* @param src
* @param offset
* @param length
* @return
*/
@Override
public byte[] encrypt(byte[] src, int offset, int length) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public byte[] decrypt(byte[] src, int offset, int length) {
throw new UnsupportedOperationException("Not supported yet.");
}
}