// Unpad will unpad the correct amount of bytes based off
// of the PKCS7 standard
976443
func (padder pkcs7Padder) Unpad(buf []byte) ([]byte, error) {
	if len(buf) == 0 {
		return nil, errPKCS7Padding
	}

	// Here be dragons. We're attempting to check the padding in constant
	// time. The only piece of information here which is public is len(buf).
	// This code is modeled loosely after tls1_cbc_remove_padding from
	// OpenSSL.
	padLen := buf[len(buf)-1]
	toCheck := pkcs7MaxPaddingSize
	good := 1
	if toCheck > len(buf) {
		toCheck = len(buf)
	}
	for i := 0; i < toCheck; i++ {
		b := buf[len(buf)-1-i]

		outOfRange := subtle.ConstantTimeLessOrEq(int(padLen), i)
		equal := subtle.ConstantTimeByteEq(padLen, b)
		good &= subtle.ConstantTimeSelect(outOfRange, 1, equal)
	}

	good &= subtle.ConstantTimeLessOrEq(1, int(padLen))
	good &= subtle.ConstantTimeLessOrEq(int(padLen), len(buf))

	if good != 1 {
		return nil, errPKCS7Padding
	}

	return buf[:len(buf)-int(padLen)], nil
}
1126355
func pad(M [][]int, power int) [][]int {
	newM := make([][]int, power)
	for i := 0; i < len(M); i++ {
		newM[i] = make([]int, power)
		copy(newM[i], M[i])
	}
	for i := len(M); i < power; i++ {
		newM[i] = make([]int, power)
	}
	return newM
}
696673
func (padder pkcs7Padder) Pad(buf []byte, n int) ([]byte, error) {
	if padder.blockSize < 1 || padder.blockSize > pkcs7MaxPaddingSize {
		return nil, awserr.New("InvalidBlockSize", "block size must be between 1 and 255", nil)
	}
	size := padder.blockSize - (n % padder.blockSize)
	pad := bytes.Repeat([]byte{byte(size)}, size)
	buf = append(buf, pad...)
	return buf, nil
}
163335
func Pad(s string) string {
	if !strings.HasSuffix(s, "=") && len(s)%8 != 0 {
		for len(s)%8 != 0 {
			s += "="
		}
	}
	return s
}
800017
func NewPad(nlines int, ncols int) *Window {
	w := new(Window)
	w.cwin = C.newpad(C.int(nlines), C.int(ncols))
	return w
}
507473
func (c *Command) UsagePadding() int {
	if c.parent == nil || minUsagePadding > c.parent.commandsMaxUseLen {
		return minUsagePadding
	}
	return c.parent.commandsMaxUseLen
}
366957
func base64DecodeNonPadded(s string) ([]byte, error) {
	if len(s)%4 != 0 {
		s = s + strings.Repeat("=", 4-len(s)%4)
	}
	return base64.StdEncoding.DecodeString(s)
}
594489
func (c *ChatPostMessageCall) UnfurlLinks(unfurlLinks bool) *ChatPostMessageCall {
	c.unfurlLinks = unfurlLinks
	return c
}
1006542
func (s *Session) unblockPin(pukpin []byte) error {
	if _, err := s.Channel.transmitEncrypted(claSCWallet, insUnblockPin, 0, 0, pukpin); err != nil {
		return err
	}
	s.verified = true
	return nil
}
67351
func (pub *PublicKey) ToBytesUncompressed() (b []byte) {
	/* See Certicom SEC1 2.3.3, pg. 10 */

	x := pub.X.Bytes()
	y := pub.Y.Bytes()

	/* Pad X and Y coordinate bytes to 32-bytes */
	padded_x := append(bytes.Repeat([]byte{0x00}, 32-len(x)), x...)
	padded_y := append(bytes.Repeat([]byte{0x00}, 32-len(y)), y...)

	/* Add prefix 0x04 for uncompressed coordinates */
	return append([]byte{0x04}, append(padded_x, padded_y...)...)
}
83355
func (o *Opts) SetPadWidth(p int) *Opts {
	o.PadWidth = p
	return o
}
114214
func UnboxBytes32(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.UnboxBytes32Arg) (bytes32 keybase1.Bytes32, err error) {
	encryptionKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceEncryptionKeyType, arg.Reason)
	if err != nil {
		return
	}

	return unboxBytes32(encryptionKey, arg.EncryptedBytes32, arg.Nonce, arg.PeersPublicKey)
}
433705
func unhex(b byte) (v byte, ok bool) {
	switch {
	case '0' <= b && b <= '9':
		return b - '0', true
	case 'a' <= b && b <= 'f':
		return b - 'a' + 10, true
	case 'A' <= b && b <= 'F':
		return b - 'A' + 10, true
	}
	return 0, false
}
86428
func (u *ubiTweak) setBitPad(value bool) {
    if value {
        u.tweak[1] |= t1FlagBitPad
    } else {
        u.tweak[1] &^= t1FlagBitPad
    }
}
722744
func pad(value string, length int) string {
	plen := length - len(value)
	if plen > 0 {
		return value + strings.Repeat(" ", plen)
	}
	return value
}
1068473
func copyWithLeftPad(dest, src []byte) {
	numPaddingBytes := len(dest) - len(src)
	for i := 0; i < numPaddingBytes; i++ {
		dest[i] = 0
	}
	copy(dest[numPaddingBytes:], src)
}
12791
func padUnits(width int, value float64, precision int, units string) string {
	format1 := fmt.Sprintf("%%-%ds", width)
	format2 := fmt.Sprintf("%%.%df%%s", precision)
	return fmt.Sprintf(format1, fmt.Sprintf(format2, value, units))
}