Skip to content

Commit 28dd9e1

Browse files
Add EncryptedRepository#getEncryptedBlobByteLength
1 parent ffe0b63 commit 28dd9e1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

x-pack/plugin/repository-encrypted/src/main/java/org/elasticsearch/repositories/encrypted/EncryptedRepository.java

+10
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ public final class EncryptedRepository extends BlobStoreRepository {
132132
// repository password on the local node
133133
private final HashVerifier passwordHashVerifier;
134134

135+
/**
136+
* Returns the byte length (i.e. the storage size) of an encrypted blob, given the length of the blob's plaintext contents.
137+
*
138+
* @see EncryptionPacketsInputStream#getEncryptionLength(long, int)
139+
*/
140+
public static long getEncryptedBlobByteLength(long plaintextBlobByteLength) {
141+
return ((long) MetadataIdentifier.byteLength()) + EncryptionPacketsInputStream.getEncryptionLength(plaintextBlobByteLength,
142+
PACKET_LENGTH_IN_BYTES);
143+
}
144+
135145
protected EncryptedRepository(RepositoryMetaData metadata, NamedXContentRegistry namedXContentRegistry, ClusterService clusterService,
136146
BlobStoreRepository delegatedRepository, Supplier<XPackLicenseState> licenseStateSupplier,
137147
char[] password) throws NoSuchAlgorithmException {

0 commit comments

Comments
 (0)