def dePemList(s, name):
 bList = []
 prefix = ('-----BEGIN %s-----' % name)
 postfix = ('-----END %s-----' % name)
 while 1:
  start = s.find(prefix)
  if (start == (-1)):
   return bList
  end = s.find(postfix, (start + len(prefix)))
  if (end == (-1)):
   raise SyntaxError('Missing PEM postfix')
  s2 = s[(start + len(prefix)):end]
  retBytes = a2b_base64(s2)
  bList.append(retBytes)
  s = s[(end + len(postfix)):]

def dePemList ( s , name ) : bList = [ ] prefix = ( '-----BEGIN %s-----' % name ) postfix = ( '-----END %s-----' % name ) while 1 : start = s . find ( prefix ) if ( start == ( - 1 ) ) : return bList end = s . find ( postfix , ( start + len ( prefix ) ) ) if ( end == ( - 1 ) ) : raise SyntaxError ( 'Missing PEM postfix' ) s2 = s [ ( start + len ( prefix ) ) : end ] retBytes = a2b_base64 ( s2 ) bList . append ( retBytes ) s = s [ ( end + len ( postfix ) ) : ]
decode a sequence of pem blocks into a list of bytearrays .