Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
What Is poi-5.2.3.jar?
What Is poi-5.2.3.jar?
✍: FYIcenter.com
poi-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which
provides an API for Microsoft document files of Word, Excel, PowerPoint, and Visio.
poi-5.2.3.jar supports Apache POI components that read and write Microsoft's OLE 2 Compound document format, which is used in early versions of Microsoft Office tools like Word 97, Excel 97, PowerPoint 97, etc.
poi-5.2.3.jar is distributed as part of the poi-bin-5.2.3-20220909.zip download file.
JAR File Size and Download Location:
JAR name: poi-5.2.3.jar Target JDK version: 9 File name: poi.jar, poi-5.2.3.jar File size: 2964641 bytes Release date: 09-09-2022 Download: Apache POI Website
Here are Java Source Code files for poi-5.2.3.jar:
⏎ org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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 org.apache.poi.poifs.crypt.binaryrc4;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.crypt.ChunkedCipherInputStream;
import org.apache.poi.poifs.crypt.CryptoFunctions;
import org.apache.poi.poifs.crypt.Decryptor;
import org.apache.poi.poifs.crypt.EncryptionHeader;
import org.apache.poi.poifs.crypt.EncryptionInfo;
import org.apache.poi.poifs.crypt.EncryptionVerifier;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
public class BinaryRC4Decryptor extends Decryptor {
private long length = -1L;
private int chunkSize = 512;
private class BinaryRC4CipherInputStream extends ChunkedCipherInputStream {
@Override
protected Cipher initCipherForBlock(Cipher existing, int block)
throws GeneralSecurityException {
return BinaryRC4Decryptor.this.initCipherForBlock(existing, block);
}
public BinaryRC4CipherInputStream(DocumentInputStream stream, long size)
throws GeneralSecurityException {
super(stream, size, chunkSize);
}
public BinaryRC4CipherInputStream(InputStream stream, int size, int initialPos)
throws GeneralSecurityException {
super(stream, size, chunkSize, initialPos);
}
}
protected BinaryRC4Decryptor() {
}
protected BinaryRC4Decryptor(BinaryRC4Decryptor other) {
super(other);
length = other.length;
chunkSize = other.chunkSize;
}
@Override
public boolean verifyPassword(String password) {
EncryptionVerifier ver = getEncryptionInfo().getVerifier();
SecretKey skey = generateSecretKey(password, ver);
try {
Cipher cipher = initCipherForBlock(null, 0, getEncryptionInfo(), skey, Cipher.DECRYPT_MODE);
byte[] encryptedVerifier = ver.getEncryptedVerifier();
byte[] verifier = new byte[encryptedVerifier.length];
cipher.update(encryptedVerifier, 0, encryptedVerifier.length, verifier);
setVerifier(verifier);
byte[] encryptedVerifierHash = ver.getEncryptedVerifierHash();
byte[] verifierHash = cipher.doFinal(encryptedVerifierHash);
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte[] calcVerifierHash = hashAlg.digest(verifier);
if (Arrays.equals(calcVerifierHash, verifierHash)) {
setSecretKey(skey);
return true;
}
} catch (GeneralSecurityException e) {
throw new EncryptedDocumentException(e);
}
return false;
}
@Override
public Cipher initCipherForBlock(Cipher cipher, int block)
throws GeneralSecurityException {
return initCipherForBlock(cipher, block, getEncryptionInfo(), getSecretKey(), Cipher.DECRYPT_MODE);
}
protected static Cipher initCipherForBlock(Cipher cipher, int block,
EncryptionInfo encryptionInfo, SecretKey skey, int encryptMode)
throws GeneralSecurityException {
EncryptionVerifier ver = encryptionInfo.getVerifier();
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
byte[] blockKey = new byte[4];
LittleEndian.putUInt(blockKey, 0, block);
byte[] encKey = CryptoFunctions.generateKey(skey.getEncoded(), hashAlgo, blockKey, 16);
SecretKey key = new SecretKeySpec(encKey, skey.getAlgorithm());
if (cipher == null) {
EncryptionHeader em = encryptionInfo.getHeader();
cipher = CryptoFunctions.getCipher(key, em.getCipherAlgorithm(), null, null, encryptMode);
} else {
cipher.init(encryptMode, key);
}
return cipher;
}
protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver) {
if (password.length() > 255) {
password = password.substring(0, 255);
}
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte[] hash = hashAlg.digest(StringUtil.getToUnicodeLE(password));
byte[] salt = ver.getSalt();
hashAlg.reset();
for (int i = 0; i < 16; i++) {
hashAlg.update(hash, 0, 5);
hashAlg.update(salt);
}
hash = Arrays.copyOf(hashAlg.digest(), 5);
return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId);
}
@Override
@SuppressWarnings({"java:S2095","resource"})
public ChunkedCipherInputStream getDataStream(DirectoryNode dir) throws IOException,
GeneralSecurityException {
DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);
length = dis.readLong();
return new BinaryRC4CipherInputStream(dis, length);
}
@Override
public InputStream getDataStream(InputStream stream, int size, int initialPos)
throws IOException, GeneralSecurityException {
return new BinaryRC4CipherInputStream(stream, size, initialPos);
}
@Override
public long getLength() {
if (length == -1L) {
throw new IllegalStateException("Decryptor.getDataStream() was not called");
}
return length;
}
@Override
public void setChunkSize(int chunkSize) {
this.chunkSize = chunkSize;
}
@Override
public BinaryRC4Decryptor copy() {
return new BinaryRC4Decryptor(this);
}
}
⏎ org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java
Or download all of them as a single archive file:
File name: poi-5.2.3-src.zip File size: 2479830 bytes Release date: 2022-09-09 Download
⇒ What Is poi-ooxml-5.2.3.jar?
⇐ What Is poi-bin-5.2.3-20220909.zip?
2017-04-04, ≈375🔥, 0💬
Popular Posts:
JDK 6 tools.jar is the JAR file for JDK 6 tools. It contains Java classes to support different JDK t...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
JDK 17 java.sql.jmod is the JMOD file for JDK 17 SQL (Structured Query Language) module. JDK 17 SQL ...
maven-core-3.5.4.jar is the JAR file for Apache Maven 3.5.4 Core module. Apache Maven is a software ...
What Is activation.jar? I heard it's related to JAF (JavaBeans Activation Framework) 1.0.2? The if y...