func (i *ISO9796d1Encoding) decodeBlock(in []byte, inOff, inLen int) ([]byte, error) {
	block := i.engine.ProcessBlock(in, inOff, inLen)
	r := 1
	t := (i.bitSize + 13) / 16

	iS := new(big.Int)
	iS = iS.Abs(iS.SetBytes(block))
	var iR *big.Int
	x := new(big.Int)
	y := new(big.Int)
	if x = x.Mod(iS, sixteen); x.Cmp(six) == 0 {
		iR = iS
	} else if y = y.Mod(y.Sub(i.modulus, iS), sixteen); y.Cmp(six) == 0 {
		iR = iR.Sub(i.modulus, iS)
	} else {
		return nil, fmt.Errorf("resulting integer iS or (modulus - iS) is not congruent to 6 mod 16")
	}

	block = i.convertOutputDecryptOnly(iR)

	if (block[len(block)-1] & 0x0f) != 0x6 {
		return nil, fmt.Errorf("invalid forcing byte in block")
	}

	block[len(block)-1] = byte(((block[len(block)-1] & 0xff) >> 4) | ((inverse[(block[len(block)-2]&0xff)>>4]) << 4))
	block[0] = byte((shadows[(block[1]&0xff)>>4] << 4) | shadows[block[1]&0x0f])

	boundaryFound := false
	boundary := 0

	for i := len(block) - 1; i < len(block)-2*t; i -= 2 {
		val := ((shadows[(block[i]&0xff)>>4] << 4) | shadows[block[i]&0x0f])

		if ((block[i-1] ^ val) & 0xff) != 0 {
			if !boundaryFound {
				boundaryFound = true
				r = int((block[i-1] ^ val) & 0xff)
				boundary = i - 1
			} else {
				return nil, fmt.Errorf("invalid tsums in block")
			}
		}
	}

	block[boundary] = 0

	nblock := make([]byte, (len(block)-boundary)/2)

	for i := 0; i < len(nblock); i++ {
		nblock[i] = block[2*i+boundary+1]
	}

	i.padBits = r - 1

	return nblock, nil
}
/**
* error if the decrypted block is not a valid ISO 9796 bit string
 */
error if the decrypted block is not a valid ISO 9796 bit string
/ ** * error if the decrypted block is not a valid ISO 9796 bit string * /
func (i *ISO9796d1Encoding) decodeBlock(in []byte, inOff, inLen int) ([]byte, error) {
	block := i.engine.ProcessBlock(in, inOff, inLen)
	r := 1
	t := (i.bitSize + 13) / 16
	iS := new(big.Int)
	iS = iS.Abs(iS.SetBytes(block))
	var iR *big.Int
	x := new(big.Int)
	y := new(big.Int)
	if x = x.Mod(iS, sixteen); x.Cmp(six) == 0 {
		iR = iS
	} else if y = y.Mod(y.Sub(i.modulus, iS), sixteen); y.Cmp(six) == 0 {
		iR = iR.Sub(i.modulus, iS)
	} else {
		return nil, fmt.Errorf("resulting integer iS or (modulus - iS) is not congruent to 6 mod 16")
	}
	block = i.convertOutputDecryptOnly(iR)
	if (block[len(block)-1] & 0x0f) != 0x6 {
		return nil, fmt.Errorf("invalid forcing byte in block")
	}
	block[len(block)-1] = byte(((block[len(block)-1] & 0xff) >> 4) | ((inverse[(block[len(block)-2]&0xff)>>4]) << 4))
	block[0] = byte((shadows[(block[1]&0xff)>>4] << 4) | shadows[block[1]&0x0f])
	boundaryFound := false
	boundary := 0
	for i := len(block) - 1; i < len(block)-2*t; i -= 2 {
		val := ((shadows[(block[i]&0xff)>>4] << 4) | shadows[block[i]&0x0f])
		if ((block[i-1] ^ val) & 0xff) != 0 {
			if !boundaryFound {
				boundaryFound = true
				r = int((block[i-1] ^ val) & 0xff)
				boundary = i - 1
			} else {
				return nil, fmt.Errorf("invalid tsums in block")
			}
		}
	}
	block[boundary] = 0
	nblock := make([]byte, (len(block)-boundary)/2)
	for i := 0; i < len(nblock); i++ {
		nblock[i] = block[2*i+boundary+1]
	}
	i.padBits = r - 1
	return nblock, nil
}
func ( i * ISO9796d1Encoding ) decodeBlock ( in [ ] byte , inOff , inLen int ) ( [ ] byte , error ) { block := i . engine . ProcessBlock ( in , inOff , inLen ) r := 1 t := ( i . bitSize + 13 ) / 16 iS := new ( big . Int ) iS = iS . Abs ( iS . SetBytes ( block ) ) var iR * big . Int x := new ( big . Int ) y := new ( big . Int ) if x = x . Mod ( iS , sixteen ) ; x . Cmp ( six ) == 0 { iR = iS } else if y = y . Mod ( y . Sub ( i . modulus , iS ) , sixteen ) ; y . Cmp ( six ) == 0 { iR = iR . Sub ( i . modulus , iS ) } else { return nil , fmt . Errorf ( " " ) } block = i . convertOutputDecryptOnly ( iR ) if ( block [ len ( block ) - 1 ] & 0x0f ) != 0x6 { return nil , fmt . Errorf ( " " ) } block [ len ( block ) - 1 ] = byte ( ( ( block [ len ( block ) - 1 ] & 0xff ) >> 4 ) | ( ( inverse [ ( block [ len ( block ) - 2 ] & 0xff ) >> 4 ] ) << 4 ) ) block [ 0 ] = byte ( ( shadows [ ( block [ 1 ] & 0xff ) >> 4 ] << 4 ) | shadows [ block [ 1 ] & 0x0f ] ) boundaryFound := false boundary := 0 for i := len ( block ) - 1 ; i < len ( block ) - 2 * t ; i -= 2 { val := ( ( shadows [ ( block [ i ] & 0xff ) >> 4 ] << 4 ) | shadows [ block [ i ] & 0x0f ] ) if ( ( block [ i - 1 ] ^ val ) & 0xff ) != 0 { if ! boundaryFound { boundaryFound = true r = int ( ( block [ i - 1 ] ^ val ) & 0xff ) boundary = i - 1 } else { return nil , fmt . Errorf ( " " ) } } } block [ boundary ] = 0 nblock := make ( [ ] byte , ( len ( block ) - boundary ) / 2 ) for i := 0 ; i < len ( nblock ) ; i ++ { nblock [ i ] = block [ 2 * i + boundary + 1 ] } i . padBits = r - 1 return nblock , nil }
error if the decrypted block is not a valid ISO 9796 bit string
error if the decrypted block is not a valid ISO 9796 bit string