public byte[] sign(Serializable obj) throws SignatureException
	{
		try
		{
			//Signature algorithm initialization
			RSAsign.initSign(keyPair.getPrivate());

			//Transform the object to be signed to a byte[]
			byte[] bytes = toBytes(obj);
			
			//Signature
			ByteArrayInputStream bufin = new ByteArrayInputStream(bytes);
			byte[] buffer = new byte[1024];
			int len;
			while (bufin.available() != 0)
			{
			    len = bufin.read(buffer);
			    RSAsign.update(buffer, 0, len);
			}
			bufin.close();
			byte[] signature = RSAsign.sign();
			return signature;
		}
		catch (InvalidKeyException ike)
		{
			//ike.printStackTrace();
			throw new SignatureException("Invalid key");
		}
		catch (IOException ioe)
		{
			//ioe.printStackTrace();
			throw new SignatureException("IO error");
		}
		catch (SignatureException se)
		{
			//se.printStackTrace();
			throw new SignatureException("Signature error");
		}
	}