< Summary

Information
Class: Renci.SshNet.Security.Cryptography.Ciphers.Paddings.PKCS5Padding
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\Ciphers\Paddings\PKCS5Padding.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 49
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
Pad(...)100%1100%
Pad(...)100%2100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\Ciphers\Paddings\PKCS5Padding.cs

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings
 4{
 5    /// <summary>
 6    /// Implements PKCS5 cipher padding.
 7    /// </summary>
 8    public class PKCS5Padding : CipherPadding
 9    {
 10        /// <summary>
 11        /// Pads the specified input to match the block size.
 12        /// </summary>
 13        /// <param name="blockSize">The size of the block.</param>
 14        /// <param name="input">The input.</param>
 15        /// <param name="offset">The zero-based offset in <paramref name="input"/> at which the data to pad starts.</par
 16        /// <param name="length">The number of bytes in <paramref name="input"/> to take into account.</param>
 17        /// <returns>
 18        /// The padded data array.
 19        /// </returns>
 20        public override byte[] Pad(int blockSize, byte[] input, int offset, int length)
 1521        {
 1522            var numOfPaddedBytes = blockSize - (length % blockSize);
 1523            return Pad(input, offset, length, numOfPaddedBytes);
 1524        }
 25
 26        /// <summary>
 27        /// Pads the specified input with a given number of bytes.
 28        /// </summary>
 29        /// <param name="input">The input.</param>
 30        /// <param name="offset">The zero-based offset in <paramref name="input"/> at which the data to pad starts.</par
 31        /// <param name="length">The number of bytes in <paramref name="input"/> to take into account.</param>
 32        /// <param name="paddinglength">The number of bytes to pad the input with.</param>
 33        /// <returns>
 34        /// The padded data array.
 35        /// </returns>
 36        public override byte[] Pad(byte[] input, int offset, int length, int paddinglength)
 1837        {
 1838            var output = new byte[length + paddinglength];
 1839            Buffer.BlockCopy(input, offset, output, 0, length);
 40
 19241            for (var i = 0; i < paddinglength; i++)
 7842            {
 7843                output[length + i] = (byte) paddinglength;
 7844            }
 45
 1846            return output;
 1847        }
 48    }
 49}