blob: 305d2a14ee173c003784805ee625f7df939115d2 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>PaddingScheme.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">Apache Shiro :: Test Coverage</a> &gt; <a href="../index.html" class="el_bundle">shiro-crypto-cipher</a> &gt; <a href="index.source.html" class="el_package">org.apache.shiro.crypto</a> &gt; <span class="el_source">PaddingScheme.java</span></div><h1>PaddingScheme.java</h1><pre class="source lang-java linenums">/*
* 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
* &quot;License&quot;); 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
* &quot;AS IS&quot; 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.shiro.crypto;
/**
* A {@code CipherPaddingScheme} represents well-known
* &lt;a href=&quot;http://en.wikipedia.org/wiki/Padding_(cryptography)&quot;&gt;padding schemes&lt;/a&gt; supported by JPA providers in a
* type-safe manner.
* &lt;p/&gt;
* When encrypted data is transferred, it is usually desirable to ensure that all 'chunks' transferred are a fixed-length:
* different length blocks might give cryptanalysts clues about what the data might be, among other reasons. Of course
* not all data will convert to neat fixed-length blocks, so padding schemes are used to 'fill in' (pad) any remaining
* space with unintelligible data.
* &lt;p/&gt;
* Padding schemes can be used in both asymmetric key ciphers as well as symmetric key ciphers (e.g. block ciphers).
* Block-ciphers especially regularly use padding schemes as they are based on the notion of fixed-length block sizes.
*
* @see &lt;a href=&quot;http://en.wikipedia.org/wiki/Padding_(cryptography)&quot;&gt;Wikipedia: Cryptographic Padding&lt;/a&gt;
* @since 1.0
*/
<span class="pc" id="L37">public enum PaddingScheme {</span>
/**
* No padding. Useful when the block size is 8 bits for block cipher streaming operations. (Because
* a byte is the most primitive block size, there is nothing to pad).
*/
<span class="fc" id="L43"> NONE(&quot;NoPadding&quot;),</span>
/**
* Padding scheme as defined in the W3C's &amp;quot;XML Encryption Syntax and Processing&amp;quot; document,
* &lt;a href=&quot;http://www.w3.org/TR/xmlenc-core/#sec-Alg-Block&quot;&gt;Section 5.2 - Block Encryption Algorithms&lt;/a&gt;.
*/
<span class="fc" id="L49"> ISO10126(&quot;ISO10126Padding&quot;),</span>
/**
* Optimal Asymmetric Encryption Padding defined in RSA's &lt;a href=&quot;http://en.wikipedia.org/wiki/PKCS1&quot;&gt;PKSC#1
* standard&lt;/a&gt; (aka &lt;a href=&quot;http://tools.ietf.org/html/rfc3447&quot;&gt;RFC 3447&lt;/a&gt;).
* &lt;p/&gt;
* &lt;b&gt;NOTE:&lt;/b&gt; using this padding requires initializing {@link javax.crypto.Cipher Cipher} instances with a
* {@link javax.crypto.spec.OAEPParameterSpec OAEPParameterSpec} object which provides the 1) message digest and
* 2) mask generation function to use for the scheme.
* &lt;h3&gt;Convenient Alternatives&lt;/h3&gt;
* While using this scheme enables you full customization of the message digest + mask generation function
* combination, it does require the extra burden of providing your own {@code OAEPParameterSpec} object. This is
* often unnecessary, because most combinations are fairly standard. These common combinations are pre-defined
* in this enum in the {@code OAEP}* variants.
* &lt;p/&gt;
* If you find that these common combinations still do not meet your needs, then you will need to
* specify your own message digest and mask generation function, either as an {@code OAEPParameterSpec} object
* during Cipher initialization or, maybe more easily, in the scheme name directly. If you want to use scheme name
* approach, the name format is specified in the
* &lt;a href=&quot;http://java.sun.com/javase/6/docs/technotes/guides/security/StandardNames.html&quot;&gt;Standard Names&lt;/a&gt;
* document in the &lt;code&gt;Cipher Algorithm Padding&lt;/code&gt; section.
*
* @see #OAEPWithMd5AndMgf1
* @see #OAEPWithSha1AndMgf1
* @see #OAEPWithSha256AndMgf1
* @see #OAEPWithSha384AndMgf1
* @see #OAEPWithSha512AndMgf1
*/
<span class="fc" id="L77"> OAEP(&quot;OAEPPadding&quot;),</span>
/**
* Optimal Asymmetric Encryption Padding with {@code MD5} message digest and {@code MGF1} mask generation function.
* &lt;p/&gt;
* This is a convenient pre-defined OAEP padding scheme that embeds the message digest and mask generation function.
* When using this padding scheme, there is no need to init the {@code Cipher} instance with an
* {@link javax.crypto.spec.OAEPParameterSpec OAEPParameterSpec} object, as it is already 'built in' to the scheme
* name (unlike the {@link #OAEP OAEP} scheme, which requires a bit more work).
*/
<span class="fc" id="L87"> OAEPWithMd5AndMgf1(&quot;OAEPWithMD5AndMGF1Padding&quot;),</span>
/**
* Optimal Asymmetric Encryption Padding with {@code SHA-1} message digest and {@code MGF1} mask generation function.
* &lt;p/&gt;
* This is a convenient pre-defined OAEP padding scheme that embeds the message digest and mask generation function.
* When using this padding scheme, there is no need to init the {@code Cipher} instance with an
* {@link javax.crypto.spec.OAEPParameterSpec OAEPParameterSpec} object, as it is already 'built in' to the scheme
* name (unlike the {@link #OAEP OAEP} scheme, which requires a bit more work).
*/
<span class="fc" id="L97"> OAEPWithSha1AndMgf1(&quot;OAEPWithSHA-1AndMGF1Padding&quot;),</span>
/**
* Optimal Asymmetric Encryption Padding with {@code SHA-256} message digest and {@code MGF1} mask generation function.
* &lt;p/&gt;
* This is a convenient pre-defined OAEP padding scheme that embeds the message digest and mask generation function.
* When using this padding scheme, there is no need to init the {@code Cipher} instance with an
* {@link javax.crypto.spec.OAEPParameterSpec OAEPParameterSpec} object, as it is already 'built in' to the scheme
* name (unlike the {@link #OAEP OAEP} scheme, which requires a bit more work).
*/
<span class="fc" id="L107"> OAEPWithSha256AndMgf1(&quot;OAEPWithSHA-256AndMGF1Padding&quot;),</span>
/**
* Optimal Asymmetric Encryption Padding with {@code SHA-384} message digest and {@code MGF1} mask generation function.
* &lt;p/&gt;
* This is a convenient pre-defined OAEP padding scheme that embeds the message digest and mask generation function.
* When using this padding scheme, there is no need to init the {@code Cipher} instance with an
* {@link javax.crypto.spec.OAEPParameterSpec OAEPParameterSpec} object, as it is already 'built in' to the scheme
* name (unlike the {@link #OAEP OAEP} scheme, which requires a bit more work).
*/
<span class="fc" id="L117"> OAEPWithSha384AndMgf1(&quot;OAEPWithSHA-384AndMGF1Padding&quot;),</span>
/**
* Optimal Asymmetric Encryption Padding with {@code SHA-512} message digest and {@code MGF1} mask generation function.
* &lt;p/&gt;
* This is a convenient pre-defined OAEP padding scheme that embeds the message digest and mask generation function.
* When using this padding scheme, there is no need to init the {@code Cipher} instance with an
* {@link javax.crypto.spec.OAEPParameterSpec OAEPParameterSpec} object, as it is already 'built in' to the scheme
* name (unlike the {@link #OAEP OAEP} scheme, which requires a bit more work).
*/
<span class="fc" id="L127"> OAEPWithSha512AndMgf1(&quot;OAEPWithSHA-512AndMGF1Padding&quot;),</span>
/**
* Padding scheme used with the {@code RSA} algorithm defined in RSA's
* &lt;a href=&quot;http://en.wikipedia.org/wiki/PKCS1&quot;&gt;PKSC#1 standard&lt;/a&gt; (aka
* &lt;a href=&quot;http://tools.ietf.org/html/rfc3447&quot;&gt;RFC 3447&lt;/a&gt;).
*/
<span class="fc" id="L134"> PKCS1(&quot;PKCS1Padding&quot;),</span>
/**
* Padding scheme defined in RSA's &lt;a href=&quot;http://www.rsa.com/rsalabs/node.asp?id=2127&quot;&gt;Password-Based
* Cryptography Standard&lt;/a&gt;.
*/
<span class="fc" id="L140"> PKCS5(&quot;PKCS5Padding&quot;),</span>
/**
* Padding scheme defined in the &lt;a href=&quot;http://www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt&quot;&gt;SSL
* 3.0 specification&lt;/a&gt;, section &lt;code&gt;5.2.3.2 (CBC block cipher)&lt;/code&gt;.
*/
<span class="fc" id="L146"> SSL3(&quot;SSL3Padding&quot;);</span>
private final String transformationName;
<span class="fc" id="L150"> private PaddingScheme(String transformationName) {</span>
<span class="fc" id="L151"> this.transformationName = transformationName;</span>
<span class="fc" id="L152"> }</span>
/**
* Returns the actual string name to use when building the {@link javax.crypto.Cipher Cipher}
* {@code transformation string}.
*
* @return the actual string name to use when building the {@link javax.crypto.Cipher Cipher}
* {@code transformation string}.
* @see javax.crypto.Cipher#getInstance(String)
*/
public String getTransformationName() {
<span class="fc" id="L163"> return this.transformationName;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html>